Skip to content

BUG: 7023 allow style when using error bars #57967

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

Closed

Conversation

thetestspecimen
Copy link
Contributor

If the 'style' parameter is passed to the DataFrame's 'plot' method at the same time as error bar parameters 'yerr' or 'xerr' (or both), then the 'style' parameter is not applied to the plot. For example, something like this:

ax = df.plot(xerr=err_x, yerr=err_y, style='or:')

will result in the marker style, color and line style being ignored.

This PR passes the style parameter to the plot.

The comments in the bug report mention a work around not working with 'subplots'. As such, I have created scenario in the tests that confirm this fix will also work for subplots.

Note: This fix is identical to that previously provided by @GLeurquin (PR #40816), but it went stale and was closed. I have basically added the missing tests that were requested, and never provided.

@@ -974,6 +974,9 @@ def _plot(
kwds["xerr"] = np.array(kwds.get("xerr"))
if "yerr" in kwds:
kwds["yerr"] = np.array(kwds.get("yerr"))
# GH 7023 allow setting plot style when using errorbars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# GH 7023 allow setting plot style when using errorbars
# GH 7023

@Aloqeely
Copy link
Member

Thanks for the PR! Sorry that this hasn't been reviewed yet. In the meantime can you fix the merge conflict?
cc @datapythonista

@@ -372,7 +372,7 @@ Period

Plotting
^^^^^^^^
-
- Bug in :meth:`MPLPlot._plot` ignoring parameter ``style`` when using error bar parameters ``yerr`` or ``xerr`` (:issue:`7023`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as in original PR, "Can you describe this in a user-facing way"?
I.E. the method that the user uses is not MPLPlot._plot but rather DataFrame.plot or Series.plot

@thetestspecimen
Copy link
Contributor Author

Thanks for the PR! Sorry that this hasn't been reviewed yet. In the meantime can you fix the merge conflict? cc @datapythonista

No problem at all.

I will take a look at your comments and get it up to date as soon as I get a minute (probably tomorrow).

@thetestspecimen
Copy link
Contributor Author

Apparently 1 check fails in relation to Unit Tests / Numpy Dev (pull_request) , but I'm not sure it has anything to do with the code:

[2024-04-21T10:31:57.779Z] ['error'] There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}
[2024-04-21T10:31:57.779Z] ['info'] Codecov will exit with status code 0. If you are expecting a non-zero exit code, please pass in the `-Z` flag

Is there something you need me to do, or a way I can re-run the checks?

@Aloqeely
Copy link
Member

This is what I'm seeing:

FAILED pandas/tests/extension/test_sparse.py::TestSparseArray::test_isna_returns_copy[0-isna] - ValueError: assignment destination is read-only
FAILED pandas/tests/extension/test_sparse.py::TestSparseArray::test_isna_returns_copy[0-notna] - ValueError: assignment destination is read-only
FAILED pandas/tests/extension/test_sparse.py::TestSparseArray::test_isna_returns_copy[nan-isna] - ValueError: assignment destination is read-only
FAILED pandas/tests/extension/test_sparse.py::TestSparseArray::test_isna_returns_copy[nan-notna] - ValueError: assignment destination is read-only
FAILED pandas/tests/indexes/test_base.py::TestIndex::test_drop_by_str_label[string] - KeyError: "['SOMEBIGLONGSTRING'] not found in axis"
FAILED pandas/tests/arrays/test_datetimelike.py::TestDatetimeArray::test_array_interface[D] - AssertionError
FAILED pandas/tests/arrays/test_datetimelike.py::TestDatetimeArray::test_array_interface[B] - AssertionError
FAILED pandas/tests/arrays/test_datetimelike.py::TestDatetimeArray::test_array_interface[W] - AssertionError
FAILED pandas/tests/arrays/test_datetimelike.py::TestDatetimeArray::test_array_interface[ME] - AssertionError
FAILED pandas/tests/arrays/test_datetimelike.py::TestDatetimeArray::test_array_interface[QE] - AssertionError
FAILED pandas/tests/arrays/test_datetimelike.py::TestDatetimeArray::test_array_interface[YE] - AssertionError
FAILED pandas/tests/arrays/test_datetimelike.py::TestTimedeltaArray::test_array_interface - AssertionError
= 12 failed, 171032 passed, 25300 skipped, 892 xfailed, 78 xpassed in 718.59s (0:11:58) =

I don't know of a better way, but, you can merge with main if you want to re-run the checks

@Aloqeely
Copy link
Member

Update: this failure seems to be happening on all PRs, you have nothing to worry about!

@thetestspecimen
Copy link
Contributor Author

Update: this failure seems to be happening on all PRs, you have nothing to worry about!

Thanks for letting me know. I thought it was a bit strange.

Let me know if you need me to force the checks to re-run (and when).

@Aloqeely
Copy link
Member

Aloqeely commented May 6, 2024

I understand you requested my review but I don't know much about the plotting code to help review this, maybe @mroeschke can help

@mroeschke
Copy link
Member

Unfortunately we don't have anyone on the core team who really understands the plotting code anymore. I can try looking later to give a high level review

@thetestspecimen
Copy link
Contributor Author

Unfortunately we don't have anyone on the core team who really understands the plotting code anymore. I can try looking later to give a high level review

No problem. The code change is very small, and was actually originally provided in PR #40816 . I have just added the tests that were missing.

Copy link
Contributor

github-actions bot commented Jun 7, 2024

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Jun 7, 2024
@thetestspecimen
Copy link
Contributor Author

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

I will update this soon to keep it available.

@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Jul 5, 2024
@thetestspecimen
Copy link
Contributor Author

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke I have merged the main branch in and pushed it to my fork of pandas. I suspect you will need to reopen before it gets pulled across here?

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

Successfully merging this pull request may close these issues.

DF Plots: Error bars don't allow to set styles
3 participants