8000 Minor example updates by QuLogic · Pull Request #7559 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 11 commits into from
Dec 17, 2016
Merged

Minor example updates #7559

merged 11 commits into from
Dec 17, 2016

Conversation

QuLogic
Copy link
Member
@QuLogic QuLogic commented Dec 4, 2016

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.

@QuLogic QuLogic added this to the 2.0.1 (next bug fix release) milestone Dec 4, 2016
self.collection = RegularPolyCollection(
fig.dpi, 6, sizes=(100,),
6, sizes=(100,),
Copy link
Member Author

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.

@Kojoley
Copy link
Member
Kojoley commented Dec 4, 2016
Some exclude patterns were unnecessary as the files they pointed to either passed the PEP8 tests or do not point to a file:
  */pyplots/dollar_ticks.py
  */pyplots/fig_axes_labels_simple.py
  */pyplots/fig_x.py

@@ -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)
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author
@QuLogic QuLogic Dec 5, 2016

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.

@QuLogic
Copy link
Member Author
QuLogic commented Dec 5, 2016

PEP8 issues should be fixed.

@QuLogic QuLogic mentioned this pull request Dec 5, 2016
@NelleV
Copy link
Member
NelleV commented Dec 5, 2016

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.

@NelleV
Copy link
Member
NelleV commented Dec 5, 2016

Thanks!

@QuLogic
Copy link
Member Author
QuLogic commented Dec 5, 2016

Updated attribution and I cleaned up the sample data for stocks. No deprecation for those as @tacaswell suggested.

@QuLogic QuLogic force-pushed the example-tweaks branch 4 times, most recently from 428230e to 8ce6cdd Compare December 6, 2016 05:31
Copy link
Member
@Kojoley Kojoley left a 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?

@QuLogic
Copy link
Member Author
QuLogic commented Dec 6, 2016

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.

@QuLogic QuLogic changed the title Minor example updates [MRG+1] Minor example updates Dec 7, 2016
QuLogic and others added 11 commits December 10, 2016 22:45
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.
@tacaswell tacaswell closed this Dec 12, 2016
@tacaswell tacaswell reopened this Dec 12, 2016
Copy link
Member
@phobson phobson left a 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')
Copy link
Member

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"?

@NelleV
Copy link
Member
NelleV commented Dec 16, 2016

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.

@QuLogic
Copy link
Member Author
QuLogic commented Dec 16, 2016

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.)

@tacaswell
Copy link
Member

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

@tacaswell tacaswell merged commit 5a3c796 into matplotlib:v2.x Dec 17, 2016
@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Dec 17, 2016
@QuLogic QuLogic changed the title [MRG+1] Minor example updates Minor example updates Dec 17, 2016
@QuLogic
Copy link
Member Author
QuLogic commented Dec 17, 2016

Thanks @tacaswell!

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

Successfully merging this pull request may close these issues.

7 participants
0