Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set xlim/ylim in plot #147

Open
dberenbaum opened this issue Dec 11, 2023 · 1 comment
Open

Set xlim/ylim in plot #147

dberenbaum opened this issue Dec 11, 2023 · 1 comment

Comments

@dberenbaum
Copy link
Contributor

See slack thread. It would be useful to have a way to set or adjust the min and max values of the axes.

@dberenbaum
Copy link
Contributor Author

Found https://stackoverflow.com/questions/73404562/can-i-set-a-dynamic-axis-value-using-vegalite. It looks possible but messy mainly because there's no easy way to get sane defaults.

Technically, you can setup dynamic limits easily. See this diff to add it to the linear template:

$ diff linear.json lims.json
18a19,42
>     },
>     {
>       "name": "xmin",
>       "bind": {
>         "input": "number"
>       }
>     },
>     {
>       "name": "xmax",
>       "bind": {
>         "input": "number"
>       }
>     },
>     {
>       "name": "ymin",
>       "bind": {
>         "input": "number"
>       }
>     },
>     {
>       "name": "ymax",
>       "bind": {
>         "input": "number"
>       }
25c49,52
<       "title": "<DVC_METRIC_X_LABEL>"
---
>       "title": "<DVC_METRIC_X_LABEL>",
>       "scale": {
>           "domain": {"expr": "[xmin, xmax]"}
>       }
57c84,85
<             "zero": false
---
>             "zero": false,
>             "domain": {"expr": "[ymin, ymax]"}

However, the plots will show as blank until you set the axis values:

Screenshot 2023-12-11 at 1 58 52 PM

To avoid this, we need to recalculate default axis limits, which requires doing a transform to calculate the extent of the data and adding it to every row in the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant