-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Minor example updates #7559
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
Minor example updates #7559
Conversation
self.collection = RegularPolyCollection( | ||
fig.dpi, 6, sizes=(100,), | ||
6, sizes=(100,), |
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.
6
-> rotation angle; not sure if the fig.dpi
was intended to produce perfect circles and the 6
should have been deleted instead.
|
@@ -12,7 +12,7 @@ | |||
datafile = cbook.get_sample_data('goog.npy') | |||
try: | |||
# Python3 cannot load python2 .npy files with datetime(object) arrays | |||
# unless the encoding is set to bytes. Hovever this option was | |||
# unless the encoding is set to bytes. However this option was | |||
# not added until numpy 1.10 so this example will only work with | |||
# python 2 or with numpy 1.10 and later | |||
price_data = np.load(datafile, encoding='bytes').view(np.recarray) |
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 you regenerate the npy under a recent py3, can you cover all cases?
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.
Not having luck with it:
$ ipython3
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.11.2'
In [3]: i = np.load('lib/matplotlib/mpl-data/sample_data/goog.npy', encoding='bytes')
In [4]: np.save('goog.npy', i)
$ python2
>>> import numpy as np
>>> np.__version__
'1.11.2'
>>> i = np.load('goog.npy')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/numpy/lib/npyio.py", line 406, in load
pickle_kwargs=pickle_kwargs)
File "/usr/lib64/python2.7/site-packages/numpy/lib/format.py", line 637, in read_array
array = pickle.load(fp, **pickle_kwargs)
ValueError: non-string names in Numpy dtype unpickling
>>> i = np.load('goog.npy', encoding='bytes')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/numpy/lib/npyio.py", line 406, in load
pickle_kwargs=pickle_kwargs)
File "/usr/lib64/python2.7/site-packages/numpy/lib/format.py", line 637, in read_array
array = pickle.load(fp, **pickle_kwargs)
ValueError: non-string names in Numpy dtype unpickling
What would probably be the most portable is np.datetime64
, but unfortunately, it appears Matplotlib doesn't handle it as well as datetime.datetime
. Probably because we didn't depend on a new enough NumPy to carry the converter in-tree.
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.
np.datetime64 has been a mess from the start. It is marginally usable now that we require numpy 1.7, so we do need to add support as best we can. Maybe someone will want to take that on for 2.1.
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.
np.datetime64
can be converted back to datetime.datetime
with arr.astype('O')
; would that look better than this current try
/except
stuff?
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 example doesn't use dates or times in any form! It is just plotting random-looking numbers that happen to come from some stock statistics. As a plotting example, it doesn't need to read data in from a file at all.
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.
Yes, but there are a couple others (just search for this same typo message in this PR) that do use the file and do use the dates, so I was mainly referring to them.
96e6e50
to
d348baf
Compare
PEP8 issues should be fixed. |
Can you please change the authorship of the last commit to @sirlittle. He's the one who put in all the effort into fixing a ticket opened by one of our own contributor which is not reflected in that cherry-pick. I think that is very unfair considering the screw up comes from our end. |
598dce8
to
c7b1b3c
Compare
Thanks! |
Updated attribution and I cleaned up the sample data for stocks. No deprecation for those as @tacaswell suggested. |
428230e
to
8ce6cdd
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 o 8000 thers. Learn more.
Closes #7457?
Oh, forgot to comment that I undid the stock data removal on @tacaswell's request as that probably won't be going into 2.0.x. |
It just shells out to mencoder, which is less available, and we've got better demos that automatically call ffmpeg or whatever with the right arguments.
svg.embed_char_paths -> svg.fonttype axisbg -> facecolor Skip 'spectral' colormap in a demo.
input() does not return until you press Enter, so be explicit about it.
Move the large label closer to the bottom spine so it appears related; remove extra whitespace around the figure.
This keeps the location in a relatively normal place. Also, fix the text to actually be different between the two objects.
8ce6cdd
to
94f47da
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.
Looks good with 1 non-blocking suggesting
@@ -25,6 +25,6 @@ | |||
ax.set_title('only every 5th errorbar') | |||
|
|||
|
|||
fig.suptitle('Errorbar subsampling for better visualibility') | |||
fig.suptitle('Errorbar subsampling for better appearance') |
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 just "Errorbar subsampling"?
This PR contains no bug fixes and large amounts of changes. These may look minor, but no change should be considered minor. This should not target 2.0 but 2.1. |
These are bug fixes for the examples if you consider that the style changes have made them appear inconsistent. The rest of the changes are documentation, which have traditionally been backported. The real large changes were removed and will go into 2.1 (but I haven't opened that PR yet.) |
The files that are not examples / doc which are touched by this are: lib/matplotlib/axes/_axes.py : correcting a docstring I missed as part of #7172 lib/matplotlib/tests/test_coding_standards.py : because more files now pass pep8 I see no reason to not put this in for 2.0 |
Thanks @tacaswell! |
I ran all the examples, and fixed any deprecations from matplotlib or NumPy (~the first half) and then fixed a few things that look wrong with the new 2.0 defaults or might be confusing (~the second half). Lastly, ran some spellcheck using PyCharm.