Conversation
|
|
||
| fig = plt.figure(1, figsize=(6, 3)) | ||
| fig, (ax1, ax2) = plt.subplots(1, 2) | ||
| fig.subplots_adjust(wspace=0.5) |
There was a problem hiding this comment.
Could be added to subplots via gridspec_kw.
There was a problem hiding this comment.
Not convinced it's an improvement in legibility...
| import matplotlib.pyplot as plt | ||
| from numpy import nonzero | ||
| from numpy.random import rand | ||
| from matplotlib import colors as mcolors, path, pyplot as plt |
There was a problem hiding this comment.
Not sure if mixed import and import as are easy to read.
There was a problem hiding this comment.
disagree, but still split it out
| """ | ||
| from matplotlib.pyplot import figure, show | ||
|
|
||
| from matplotlib import pyplot as plt |
There was a problem hiding this comment.
import matplotlib.pyplot as plt (also in various other locations, please search/replace)
| # plot specifying units | ||
| ax2.plot(x, y, 'o', xunits=2.0) | ||
| ax2.set_title("xunits = 2.0") | ||
| plt.setp(ax2.get_xticklabels(), rotation=30, ha='right') |
There was a problem hiding this comment.
Broadcasting explicitly to a list of tick labels feels a bit clumsy. Is there maybe a method to set this for all tick labels, e.g. tick_params or similar?
There was a problem hiding this comment.
tick_params can set labelrotation, but not horizontalalignment (and I don't think it's worth changing that, IMO setp actually does this job perfectly well...).
| label.set_ha('right') | ||
| ax1.plot(x, y) # uses default units | ||
| ax1.set_title('default units') | ||
| plt.setp(ax1.get_xticklabels(), rotation=30, ha='right') |
| t = arange(0.0, 3.0, 0.01) | ||
| s = sin(2*pi*t) | ||
| t = np.arange(0.0, 3.0, 0.01) | ||
| s = np.sin(2*np.pi*t) |
There was a problem hiding this comment.
Do we have a convention, if this should include spaces around the operators? PEP8 would want them. Throughout the examples both variants are used.
There was a problem hiding this comment.
See discussion at #7562 (comment) which I now agree with: I still believe spaces are in general good, but in some cases no spaces read better.
See also https://www.python.org/dev/peps/pep-0008/#other-recommendations ("use your own judgment", hehe).
- don't import out of pyplot or numpy, import as plt/np. - move some examples to use subplots() instead of add_subplot. - set random seed for some examples. - fix some docstrings.
PR Summary
PR Checklist