Skip to content

coordinate limits does not work on reversed scales #1365

@x-EricH-x

Description

@x-EricH-x

Description

When a trans="reverse" is applied on a scale, setting coordinate limits will trigger
Invalid coord x-limits (or Invalid coord y-limits)

The relevant source is likely this part (link):

require(
            xLim.first == null || xLim.second == null ||
                    xLim.second!! > xLim.first!!
        ) { "Invalid coord x-limits: $xLim " }
        require(
            yLim.first == null || yLim.second == null ||
                    yLim.second!! > yLim.first!!

Code snippet

import numpy as np
from lets_plot import *
LetsPlot.setup_html()
np.random.seed(42)
n = 20
data = {
    "x": np.random.randint(5, size=n),
    'y': np.random.randint(5, size=n),
}
(
    ggplot(data, aes(x="x", y="y"))
    + geom_point()
    + scale_x_continuous(expand=[0, 0], trans="reverse")
    + scale_y_continuous(expand=[0, 0])
    # + coord_polar(theta='y', xlim=[0, 5]) # error
    # + coord_polar(theta='y', xlim=[5 ,0]) # error
    # + coord_polar(theta='y', xlim=[None, 5]) # ok
    # + coord_polar(theta='y', xlim=[5, None]) # ok
    + coord_polar(theta='y') # ok
)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions