-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Style changes omnibus PR #5774
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
Style changes omnibus PR #5774
Changes from 21 commits
14281fd
76c70be
bba003f
86b7a59
d2f6bea
87ba8b0
38d4e31
5317d35
5695389
3e7471a
28c632f
4472125
f45e9bc
4513182
09b29d8
3abcb95
f2ac1bb
318a044
417db2f
82558ee
c5864ce
30b4341
0f4e3a6
c44bd3d
fa4c56e
caa711b
c2580a5
f0e98fa
7718b15
0aae0f0
f21d5cf
31f28bc
b394ae7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
Changes to the default style | ||
---------------------------- | ||
|
||
The most important changes in matplotlib 2.0 are the changes to the | ||
default style. | ||
|
||
While it is impossible to select the best default for all cases, these | ||
are designed to work well in the most common cases. | ||
|
||
These changes include: | ||
|
||
Colors | ||
`````` | ||
|
||
- The default figure background color has changed from grey to white. | ||
|
||
- The default cycle of colors to draw lines, markers and other content | ||
has been changed. It is based on the `Vega category10 palette | ||
<https://github.com/vega/vega/wiki/Scales#scale-range-literals>`__. | ||
|
||
- The default color map used for images and pcolor meshes, etc., has | ||
changed from ``jet`` to ``viridis``. | ||
|
||
- For markers, scatter plots, bar charts and pie charts, there is no | ||
longer a black outline around filled markers by default. | ||
|
||
- Grid lines are light grey solid 1pt lines. They are no longer dashed by | ||
default. | ||
|
||
- The ''Blues'' colormap has been adjusted to be perceptually uniform. | ||
The old ``blues`` colormap is available under the name | ||
``legacy_Blues``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that PR has been merged yet, and I'm not sure I see it in this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry -- I meant to cherry-pick it here. That's now done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've actually decided to backtrack on this one. See #4681. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so the comments about the Blue colormap should be removed, right? |
||
|
||
Plot layout | ||
``````````` | ||
|
||
- The default dpi used for on-screen is now 100, which is the same as | ||
the old default for saving files. Due to this, the on-screen | ||
display is now more what-you-see-is-what-you-get. | ||
|
||
- The number of ticks on an axis is now automatically determined based | ||
on the length of the axis. | ||
|
||
- The limits are scaled to exactly the dimensions of the data, plus 5% | ||
padding. The old behavior was to scale to the nearest "round" | ||
numbers. To use the old behavior, set the ``rcParam`` | ||
``axes.autolimit_mode`` to ``round_numbers``. | ||
|
||
- Ticks now point outward by default. To have ticks pointing inward, | ||
use the ``rcParams`` ``xtick.direction`` and ``ytick.direction``. | ||
|
||
- By default, caps on the ends of errorbars are not present. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this controlable via rcParams? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. It's errorbar.capsize. I'll add a note here. |
||
|
||
Images | ||
`````` | ||
|
||
- The default mode for image interpolation is now ``nearest``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should mention the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry -- it's in my git index -- forgot to commit. |
||
|
||
- The default shading mode is now ``overlay``. Formerly, it was | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should reference the function where that applies? It doesn't appear to be controlled by an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do you mention a function for shading? |
||
``hsv``. | ||
|
||
- The default value for ``image.resample`` is now ``True``. This will | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entry doesn't state that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, you say "Done", but I don't see any change. |
||
apply interpolation for both upsampling and downsampling of an | ||
image. | ||
|
||
Fonts | ||
````` | ||
|
||
- The default font has changed from "Bitstream Vera Sans" to "DejaVu | ||
Sans". "DejaVu Sans" is an improvement on "Bistream Vera Sans" that | ||
adds more international and math characters, but otherwise has the | ||
same appearance. | ||
|
||
- The default math font when using the built-in math rendering engine | ||
(mathtext) has changed from "Computer Modern" (i.e. LaTeX-like) to | ||
"DejaVu Sans". To revert to the old behavior, set the ``rcParam`` | ||
``mathtext.fontset`` to ``cm``. This change has no effect if the | ||
TeX backend is used (i.e. ``text.usetex`` is ``True``). | ||
|
||
Dates | ||
````` | ||
|
||
- The default date formats are now all based on ISO format, i.e., with | ||
the slowest-moving value first. The date formatters are still | ||
changeable through the ``date.autoformatter.*`` rcParams. Python's | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not seeing these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's from #5445. I've rebased this on that, so it's here now (but still won't show up in the diff, obviously). |
||
``%x`` and ``%X`` date formats may be of particular interest to | ||
format dates based on the current locale. | ||
|
||
Legends | ||
``````` | ||
|
||
- By default, the number of points displayed in a legend is now 1. | ||
|
||
- The default legend location is ``best``, so the legend will be | ||
automatically placed in a location to obscure the least amount of | ||
data possible. | ||
|
||
- The legend now has rounded corners by default. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,9 +61,11 @@ def filled_hist(ax, edges, values, bottoms=None, orientation='v', | |
values = np.r_[values, values[-1]] | ||
bottoms = np.r_[bottoms, bottoms[-1]] | ||
if orientation == 'h': | ||
return ax.fill_betweenx(edges, values, bottoms, **kwargs) | ||
return ax.fill_betweenx(edges, values, bottoms, left_margin=False, | ||
**kwargs) | ||
elif orientation == 'v': | ||
return ax.fill_between(edges, values, bottoms, **kwargs) | ||
return ax.fill_between(edges, values, bottoms, bottom_margin=False, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like some sort of suggested change that people should make, but it isn't noted in the change list above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point. I'll add this to the existing bullet point about limits. |
||
**kwargs) | ||
else: | ||
raise AssertionError("you should never be here") | ||
|
||
|
@@ -206,3 +208,5 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None, | |
ax1.set_xlabel('counts') | ||
ax1.set_ylabel('x') | ||
ax2.set_ylabel('x') | ||
|
||
plt.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,9 @@ | |
|
||
for i, gamma in enumerate(gammas): | ||
plt.subplot(xgrid, ygrid, i + 2) | ||
plt.title('Power law normalization\n$(\gamma=%1.1f)$' % gamma) | ||
plt.title('Power law\n$(\gamma=%1.1f)$' % gamma) | ||
plt.hist2d(data[:, 0], data[:, 1], | ||
bins=100, norm=mcolors.PowerNorm(gamma)) | ||
|
||
plt.subplots_adjust(hspace=0.39) | ||
plt.subplots_adjust(hspace=0.8) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uhm, that's a lot of space... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but it's required to make room for the text. I suppose I could use tight_layout instead... that seems to work and it less "tweaky". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think tight_layout makes more sense, too. Should probably consider it in more places, too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than calling |
||
plt.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,6 @@ | |
fig = plt.figure() | ||
ax = fig.gca(projection='3d') | ||
|
||
ax.plot_trisurf(x, y, z, cmap=cm.jet, linewidth=0.2) | ||
ax.plot_trisurf(x, y, z, cmap=cm.jet, linewidth=0.2, antialiased=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should probably get rid of the use of Jet here. Also, isn't antialiasing turned on by default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. antialiasing is turned off on pcolormesh by default to get around the polygon edge gap problem. I'll just take the explicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right. Because we are taking the edges off of the polygons, the gaps would be apparent. How about we make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not a change in behavior. pcolormesh has had no borders and antialiased=False for a long time. I don't think it makes sense to change that. The change here is just that it happens to look better with the new colormap on this specific data so why not? |
||
|
||
plt.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ | |
|
||
t = np.arange(0.0, 5.0, 0.01) | ||
s = np.cos(2*np.pi*t) | ||
line, = ax.plot(t, s, lw=3, color='purple') | ||
line, = ax.plot(t, s, lw=3) | ||
|
||
ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction', | ||
horizontalalignment='center', verticalalignment='center') | ||
|
@@ -97,7 +97,7 @@ | |
ax = fig.add_subplot(111, projection='polar') | ||
r = np.arange(0, 1, 0.001) | ||
theta = 2*2*np.pi*r | ||
line, = ax.plot(theta, r, color='#ee8d18', lw=3) | ||
line, = ax.plot(theta, r) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The linewidth was kept in the previous plot call, why not here, too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should probably take it off in both cases, actually, so it will take the new defaults. (This example isn't about how to change the linewidth). |
||
|
||
ind = 800 | ||
thisr, thistheta = r[ind], theta[ind] | ||
|
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.
I see this change in the template, but not in
rcsetup.py
; is it fully implemented? (I assume it'sfigure.facecolor
).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.
Good catch. It should be in rcsetup.py as well. Done.