-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add new ax feature #109
Add new ax feature #109
Conversation
@FloraSauerbronn When creating multiple figures or, of the user already passed an inverted axis, the call to invert it will undo this. We need to check if the axis is inverted first, and then invert it if not. See https://github.com/pyoceans/python-ctd/blob/10883153b27d296ef038252fe8f8604c79cd3a49/ctd/plotting.py#L30-L33 for a pattern on how to achieve this. |
@FloraSauerbronn we also need to write some tests for this functionality. We can probably write two to cover the 3 cases in the notebook above.
|
Co-authored-by: Filipe <[email protected]>
… in plot_transect
@@ -85,6 +85,9 @@ def plot_transect( | |||
cbar = fig.colorbar(cs, orientation="vertical", extend="both") | |||
cbar.ax.set_ylabel(var) | |||
ax.set_ylabel("pressure") | |||
|
|||
ax.set_ylim(ax.get_ylim()[0], 0) |
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.
@FloraSauerbronn this one looks good! Let's remove the comments that are describing what the code is doing and add some docstrings to these functions?
Docstrings can be simple descriptions of test.
|
||
@pytest.mark.mpl_image_compare(baseline_dir=root.joinpath("baseline/")) | ||
def test_plot_track(glider_data): | ||
# Generate the 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.
# Generate the plot |
@pytest.mark.mpl_image_compare(baseline_dir=root.joinpath("baseline/")) | ||
def test_plot_track(glider_data): | ||
# Generate the plot | ||
fig, ax = plot_track(glider_data) | ||
# Return the figure for pytest-mpl to compare |
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.
# Return the figure for pytest-mpl to compare |
|
||
glider_grab.fetcher.dataset_id = "whoi_406-20160902T1700" | ||
df = glider_grab.to_pandas() | ||
def test_plot_transect(glider_data): | ||
# Generate the 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.
# Generate the plot |
# Generate the plot | ||
fig, ax = plot_transect(df, 'temperature') | ||
fig, ax = plot_transect(glider_data, 'temperature') | ||
# Return the figure for pytest-mpl to compare |
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.
# Return the figure for pytest-mpl to compare |
|
||
@pytest.mark.mpl_image_compare(baseline_dir=root.joinpath("baseline/")) | ||
def test_plot_transect_multiple_figures(glider_data): | ||
# Generate the plot with multiple figures |
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.
# Generate the plot with multiple figures |
# Generate the plot with multiple figures | ||
fig, (ax0, ax1) = plt.subplots(figsize=(15, 9), nrows=2, sharex=True, sharey=True) | ||
glider_data.plot_transect(var="temperature", ax=ax0) | ||
glider_data.plot_transect(var="salinity", ax=ax1, cmap=cmcrameri.cm.davos) | ||
# Return the figure for pytest-mpl to compare |
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.
# Return the figure for pytest-mpl to compare |
# Return the figure for pytest-mpl to compare | ||
return fig | ||
|
||
def test_plot_transect_size(glider_data): | ||
# Generate the plot with a specific size |
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.
# Generate the plot with a specific size |
@FloraSauerbronn I believe that all the changes here are part of the merged #114, right? |
Yes, all the changes are in #114 |
New ax feature for plot_transect function in plotting.py