-
-
Notifications
You must be signed in to change notification settings - Fork 111
Document the size and layout options #1545
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
doc/ref/plot_options/size.ipynb:12
- [nitpick] Consider standardizing the capitalization for consistency; the notebook header uses 'Size and Layout Options' while this directive uses 'Size And Layout Options'.
.. plotting-options-table:: Size And Layout Options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few quick questions on the options:
- Should fontsize and fontscale be in the same option group?
- Should aspect and data_aspect be in this size and layout group?
doc/ref/plot_options/size.ipynb
Outdated
"source": [ | ||
"## `frame_width / frame_height`\n", | ||
"\n", | ||
"The `frame_width` and `frame_height` options determine the width and height of the data area within the plot. They define the size of the plot’s core region (excluding axes, legends, and margins), allowing precise control over how the data is displayed." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool, I had never really thought about this (or forgot!). Like in HoloViews docs, it could be nice to show two plots with frame_height/width set, one without a legend or colorbar and one with, to see the inner plots have the same dimension.
doc/ref/plot_options/size.ipynb
Outdated
"import hvplot.xarray # noqa\n", | ||
"import hvsampledata\n", | ||
"\n", | ||
"df = hvsampledata.air_temperature(\"xarray\")\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pick just one timestamp to avoid the non-interactive widgets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
doc/ref/plot_options/size.ipynb
Outdated
"import hvplot.xarray # noqa\n", | ||
"import hvsampledata\n", | ||
"\n", | ||
"df = hvsampledata.air_temperature(\"xarray\")\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pick just one timestamp to avoid the non-interactive widgets.
doc/ref/plot_options/size.ipynb
Outdated
"import hvplot.xarray # noqa\n", | ||
"import hvsampledata\n", | ||
"\n", | ||
"df = hvsampledata.air_temperature(\"xarray\")\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pick just one timestamp to avoid the non-interactive widgets.
doc/ref/plot_options/size.ipynb
Outdated
"source": [ | ||
"## `padding`\n", | ||
"\n", | ||
"The `padding` option expands the plot’s automatically computed axis limits by a given fraction. When hvPlot determines the x and y ranges based on your data, it finds the minimum and maximum values needed to display all points. With padding applied, these ranges are extended by the specified fraction so that data points near the edges have more space. The padding value can be given as a single number for uniform padding, a tuple to specify different padding for the x- and y-axes, or even a nested tuple to set distinct padding for the upper and lower bounds of each axis." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's a good idea to set tiles=True
in this example (the axes are distributed differently). Might be best to use a simpler dummy and more geometric dataset in this case.
Something like this maybe:
import pandas as pd
df = pd.DataFrame({'x': [0, 1, 0, -1], 'y': [-1, 0, 1, 0]})
df.hvplot.scatter(x='x', y='y', padding=(0.5, 0.1))
doc/ref/plot_options/size.ipynb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the file be named size_and_layout
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unnecessarily long IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about size_layout
? More descriptive URL helps with SEO I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
Yeah, I think so. I'll move
Hmm, I think so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR documents the new Size and Layout options for plots and updates internal option categorizations accordingly.
- Introduces the new options “aspect” and “data_aspect” with detailed documentation.
- Reassigns the “fontscale” option from the Size and Layout section to the Axis Options.
- Updates the documentation index and adds a new notebook detailing these changes.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
hvplot/converter.py | Updates docstrings and internal option lists to reclassify axis and size/layout options. |
doc/ref/plotting_options/size_layout.ipynb | Adds a comprehensive notebook demonstrating the new size and layout options. |
doc/ref/plotting_options/index.md | Links the new size/layout documentation for easier navigation. |
Comments suppressed due to low confidence (1)
hvplot/converter.py:378
- Since 'fontscale' has been reclassified to the Axis Options, ensure the accompanying documentation consistently reflects its new categorization and rationale for the change.
fontscale : number
@@ -511,7 +511,8 @@ class HoloViewsConverter: | |||
] | |||
|
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed a few minor changes and left some comments that are mostly about aspect
.
"\n", | ||
"The `aspect` option controls the overall shape of the plot by setting the ratio of its width to its height.\n", | ||
"You can specify 'auto', 'equal', or a numeric value:\n", | ||
"- 'auto': The plot determines its own aspect ratio (default).\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried setting aspect='auto'
and got an error. It's important that we try the options we document to make sure they work and do what we expect.
File [~/dev/hvplot/.pixi/envs/docs/lib/python3.11/site-packages/holoviews/plotting/plot.py:1376](http://localhost:8889/lab/workspaces/auto-h/tree/~/dev/hvplot/.pixi/envs/docs/lib/python3.11/site-packages/holoviews/plotting/plot.py#line=1375), in GenericElementPlot.get_padding(self, obj, extents)
1374 yspan = y1-y0 if util.is_number(y0) and util.is_number(y1) else None
1375 aspect = self.get_aspect(xspan, yspan)
-> 1376 if aspect > 1:
1377 xpad = tuple(xp[/](http://localhost:8889/aspect)[aspect](http://localhost:8889/aspect) for xp in xpad) if isinstance(xpad, tuple) else xpad[/](http://localhost:8889/aspect)[aspect](http://localhost:8889/aspect)
1378 else:
TypeError: '>' not supported between instances of 'str' and 'int'
"The `aspect` option controls the overall shape of the plot by setting the ratio of its width to its height.\n", | ||
"You can specify 'auto', 'equal', or a numeric value:\n", | ||
"- 'auto': The plot determines its own aspect ratio (default).\n", | ||
"- 'equal': Ensures the axes have the same scaling (e.g. for square plots).\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with for square plots?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I tried passing down aspect='square'
and that worked too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in a case like that where the argument accepts a few values, it's good to show them all. Let me know what you think.
(
df.hvplot.scatter(x='bill_length_mm', y='bill_depth_mm', frame_width=200)
+ df.hvplot.scatter(x='bill_length_mm', y='bill_depth_mm', frame_width=200, aspect=0.6)
+ df.hvplot.scatter(x='bill_length_mm', y='bill_depth_mm', frame_width=200, aspect='square')
+ df.hvplot.scatter(x='bill_length_mm', y='bill_depth_mm', frame_width=200, aspect='equal')
).cols(2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a better example. I've used it in the notebook instead of the former one.
"id": "c99dceda-b76f-450a-90ac-06735a1b001c", | ||
"metadata": {}, | ||
"source": [ | ||
"## `frame_width / frame_height`\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"id": "de030cee-46a2-4d8d-b12a-e685bd616e27", | ||
"metadata": {}, | ||
"source": [ | ||
"## `data_aspect`\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to write which option takes precedence between aspect and data_aspect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, aspect
and data_aspect
do different things. aspect
controls the shape of the plot i.e, ratio of frame_width to frame_height while data_aspect
controls the scaling of the data units i.e, ratio of the unit on the x-axis to the unit on the y-axis.
I've modified the documentation to be more explanatory.
"(option-aspect)=\n", | ||
"## `aspect`\n", | ||
"\n", | ||
"The `aspect` option controls the **frame** shape by setting the ratio of its width to its height. By default (`aspect=None`), HoloViews chooses an appropriate ratio automatically. Use:\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To understand, what do you mean with HoloViews choosing an appropriate ratio automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means the ratio used is either the default or the specified frame width/height. I think I'll have to rewrite that as it is a bit vague.
fixes #1544
This PR adds the Size and Layout options to the reference docs.