-
-
Notifications
You must be signed in to change notification settings - Fork 113
Improve documentation of Plot methods #1548
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
|
The signature defs in the |
| "\n", | ||
| "df = hvsampledata.penguins(\"pandas\")\n", | ||
| "\n", | ||
| "stacked_df = df.groupby(\"species\")[[\"bill_length_mm\", \"bill_depth_mm\"]].mean().reset_index()\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 don't think calling reset_index() is required?
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### Simple vertical bar plot" |
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.
If possible, it'd be nice if the first example could be independent of hvsampledata (e.g. with dummy data generated with pandas/numpy), so users who don't have it installed have one chance to run this one easily.
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 think you can borrow a bit more from https://hvplot.holoviz.org/reference/tabular/bar.html:
- multi-index
- wide vs long data
I also like the short sentences that precede the 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.
It would be nice to show at least in one cell the .head() of the penguins dataset. Also I think I'd be in favor of showing at least in one cell the content of stacked_df. Pandas users wouldn't struggle too much understanding the shape of this dataframe but it's still cognitive load we can avoid.
| "df = hvsampledata.earthquakes(\"pandas\")\n", | ||
| "\n", | ||
| "TBD" | ||
| "df.hvplot.scatter(\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 seems to me this is a bit of a too "complicated" example (tiles) for the first one on this page.
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. Will change it.
| A color or a Field name to draw the color of the marker from | ||
| s : int, optional, also available as 'size' | ||
| The size of the marker | ||
| by : string, optional |
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 think these options were added by Marc when he improved all the docstrings. I understand why he did that, to make them available in VS Code when you use hvPlot as follows:
from hvplot import hvPlot
hvPlot(df).scatter(...
It duplicates docstrings which isn't good. Removing them affects the UX in an IDE, which isn't good either. I'll open an issue to track this, I think we could define a subset of important options all methods should have (or have a way to declare which generic options a given method should be augmented with in its docstring), and have a pre-commit step that makes sure we don't have to manually duplicate docstrings.
|
I just pushed 8878346 to reset this PR so i can figure out the directory tree much more easily. Still a WIP. |
| " y=\"Apple\",\n", | ||
| " y2=\"Microsoft\",\n", | ||
| " alpha=0.4,\n", | ||
| " line_color=\"#e87508\",\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 should be possible to set a different line_color for each individual line in the plot (y and y2) but right now it's not.
| "## Examples\n", | ||
| "\n", | ||
| "TBD" | ||
| "### `Filled Contours for Temperature Regions`\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.
Why is there even a contourf element instead of just adding the filled paramater to the contour element?
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 think that's why: https://docs.xarray.dev/en/latest/generated/xarray.plot.contourf.html
| "id": "b27350ca", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "# hvPlot.dataset\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.
How many people actually use this element in real life? Is it necessary to continue maintaining it?
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.
Probably very few. Might be good to ask Philipp for feedback.
maximlt
left a comment
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 while ago already I added some inline review comments. I've reviewed the documented notebooks, modified them a bit, and added the missing ones. This is good to go, thanks @Azaya89 !!!
| 'sphinxext.rediraffe', | ||
| 'numpydoc', | ||
| 'sphinxcontrib.mermaid', | ||
| 'sphinx.ext.intersphinx', |
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.
Already added in nbsite.
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### `Stacked Area for Multiple Series`\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've removed the quotes in the headings.
| "import hvplot.pandas # noqa\n", | ||
| "import hvsampledata\n", | ||
| "\n", | ||
| "df = hvsampledata.stocks(\"pandas\")\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.
Changed this example in favor of apple_stocks and display low/high prices area (I thought it was a more realistic use case).
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.
Reworked it a bit to use a dataset that makes a bit more sense when using stacked=True.
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### `Combining contourf with Transparency`\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.
In general, in these pages the focus should be on documenting the plot-specific options, like levels in this case, which has no example on this page.
| "import numpy as np\n", | ||
| "\n", | ||
| "df = pd.DataFrame({'values': np.random.normal(loc=0, scale=1, size=1000)})\n", | ||
| "df.hvplot.hist(y='values', bin_range=(-1, 1), title='Histogram in Range -1 to 1') # Didn't work?" |
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.
Yep we broke it in https://github.com/holoviz/hvplot/pull/1523/files#diff-6fcc94abe23802d29dfb077516afd7d60aba62add0f905a6ada0884a3bd006b5R1418. Tracking this in #1623 (comment).
| "source": [ | ||
| "### Basic Histogram with bins\n", | ||
| "\n", | ||
| "You can control the number of bins or specify bin edges." |
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 a reference document, we can add more examples that go beyond the simplest one.
| ".. backend-styling-options:: ohlc\n", | ||
| "```\n", | ||
| "\n", | ||
| "## Examples\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.
The gallery page (https://hvplot.holoviz.org/reference/tabular/ohlc.html) contains an example describing how neg_color, pos_color, line_color and bar_width can be used to control the plot display. These are keywords specific to this plot. I've documented them.
| "## Examples\n", | ||
| "\n", | ||
| "TBD" | ||
| "### `Lissajous Curve`\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.
Nice to have a non-geographic example but still I think that's likely to be the most common use case and why it was included in the reference gallery (https://hvplot.holoviz.org/reference/tabular/paths.html).
closes #1536
This PR adds API reference examples to the following plot methods: