Skip to content

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

Merged
merged 33 commits into from
Feb 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
14281fd
Change default image interpolation to nearest
jenshnielsen Jul 10, 2015
76c70be
Change docstring to reflect new default interpolation
jenshnielsen Jul 10, 2015
bba003f
fix typo
jenshnielsen Nov 6, 2015
86b7a59
fix #4854: set default numpoints of legend entries to 1
gauteh Sep 24, 2015
d2f6bea
Fix #5419: Set default figure background to white
mdboom Dec 14, 2015
87ba8b0
Don't plot errorbar caps by default
mdboom Dec 14, 2015
38d4e31
Grey solid tick lines
mdboom Nov 8, 2015
5317d35
API: use 'best' for default legend location
tacaswell Nov 9, 2015
5695389
Outward ticks (Fix #4502)
mdboom Nov 16, 2015
3e7471a
Use "new" blue by default
mdboom Nov 16, 2015
28c632f
Change default color map (Fix #875)
mdboom Nov 16, 2015
4472125
Use Vega collection10 colors instead
mdboom Nov 17, 2015
f45e9bc
Rounded corners on legend box
mdboom Dec 14, 2015
4513182
Fix #4700: Use overlay by default
mdboom Nov 17, 2015
09b29d8
Simplify examples to use defaults more often
mdboom Nov 25, 2015
3abcb95
Add what's new
mdboom Dec 14, 2015
f2ac1bb
Document Xtick.minor.visible
mdboom Dec 14, 2015
318a044
Use image.resample == True
mdboom Dec 31, 2015
417db2f
Update test images
mdboom Dec 31, 2015
82558ee
Revert some changes caught by @QuLogic in review
mdboom Jan 21, 2016
c5864ce
Fix typo
mdboom Jan 22, 2016
30b4341
Update test images
mdboom Dec 31, 2015
0f4e3a6
Improve what's new
mdboom Jan 25, 2016
c44bd3d
Fix formatting
mdboom Jan 25, 2016
fa4c56e
Change figure background for real
mdboom Jan 25, 2016
caa711b
More detail in what's new
mdboom Jan 26, 2016
c2580a5
Remove info about Blues colormap -- we're punting
mdboom Jan 26, 2016
f0e98fa
USe tight_layout rather than hardcoded space
mdboom Jan 26, 2016
7718b15
Don't use jet
mdboom Jan 26, 2016
0aae0f0
Don't hardcode linewidth
mdboom Jan 26, 2016
f21d5cf
Fix comment
mdboom Jan 26, 2016
31f28bc
Fix comment
mdboom Jan 26, 2016
b394ae7
Add missing test file
mdboom Jan 27, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions doc/users/whats_new/rcparams.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Configuration (rcParams)
``svg.hashsalt``
````````````````

If ``svg.hashsalt`` is ``None`` (which it is by default), the svg backend uses ``uuid4`` to generate the hash salt.
If it is not ``None``, it must be a string that is used as the hash salt instead of ``uuid4``.
This allows for deterministic SVG output.
If ``svg.hashsalt`` is ``None`` (which it is by default), the svg
backend uses ``uuid4`` to generate the hash salt. If it is not
``None``, it must be a string that is used as the hash salt instead of
``uuid4``. This allows for deterministic SVG output.
105 changes: 105 additions & 0 deletions doc/users/whats_new/style_changes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
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.
Copy link
Member

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's figure.facecolor).

Copy link
Member Author

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.

Use the rcParam ``figure.facecolor`` to control this.

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

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``. To control the
margins on particular side individually, pass any of the following
to any artist or plotting function:

- ``top_margin=False``
- ``bottom_margin=False``
- ``left_margin=False``
- ``right_margin=False``

- 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. Use the
rcParam ``errorbar.capsize`` to control this.

Images
``````

- The default mode for image interpolation, in the rcParam
``image.interpolation``, is now ``nearest``.

- The default shading mode for light source shading, in
``matplotlib.colors.LightSource.shade``, is now ``overlay``.
Formerly, it was ``hsv``.

- The default value for the rcParam ``image.resample`` is now
``True``. This will 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
Copy link
Member

Choose a reason for hiding this comment

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

I'm not seeing these rcParams in this branch.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
6 changes: 3 additions & 3 deletions examples/api/demo_affine_image.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def imshow_affine(ax, z, *kl, **kwargs):

fig, (ax1, ax2) = plt.subplots(1, 2)
Z = get_image()
im1 = imshow_affine(ax1, Z, interpolation='none', cmap=cm.jet,
im1 = imshow_affine(ax1, Z, interpolation='none',
origin='lower',
extent=[-2, 4, -3, 2], clip_on=True)

Expand All @@ -48,15 +48,15 @@ def imshow_affine(ax, z, *kl, **kwargs):
x1, x2, y1, y2 = im1.get_extent()
x3, y3 = x2, y1

ax1.plot([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], "r--", lw=3,
ax1.plot([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], "--",
transform=trans_data2)

ax1.set_xlim(-3, 5)
ax1.set_ylim(-4, 4)

# image skew

im2 = ax2.imshow(Z, interpolation='none', cmap=cm.jet,
im2 = ax2.imshow(Z, interpolation='none',
origin='lower',
extent=[-2, 4, -3, 2], clip_on=True)
im2._image_skew_coordinate = (3, -2)
Expand Down
8 changes: 6 additions & 2 deletions examples/api/filled_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

The 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")

Expand Down Expand Up @@ -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()
3 changes: 1 addition & 2 deletions examples/api/histogram_path_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
barpath = path.Path.make_compound_path_from_polys(XY)

# make a patch out of it
patch = patches.PathPatch(
barpath, facecolor='blue', edgecolor='gray', alpha=0.8)
patch = patches.PathPatch(barpath, facecolor='blue')
ax.add_patch(patch)

# update the view limits
Expand Down
2 changes: 1 addition & 1 deletion examples/api/image_zcoord.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
X = 10*np.random.rand(5, 3)

fig, ax = plt.subplots()
ax.imshow(X, cmap=cm.jet, interpolation='nearest')
ax.imshow(X, interpolation='nearest')

numrows, numcols = X.shape

Expand Down
2 changes: 1 addition & 1 deletion examples/api/patch_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
patches.append(polygon)

colors = 100*np.random.rand(len(patches))
p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4)
p = PatchCollection(patches, alpha=0.4)
p.set_array(np.array(colors))
ax.add_collection(p)
plt.colorbar(p)
Expand Down
5 changes: 3 additions & 2 deletions examples/api/power_norm_demo.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

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

plt.show()
6 changes: 2 additions & 4 deletions examples/api/sankey_demo_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@
orientations=[-1, 1, 0, 1, 1, 1, -1, -1, 0],
pathlengths=[0.25, 0.25, 0.25, 0.25, 0.25, 0.6, 0.25, 0.25,
0.25],
patchlabel="Widget\nA",
alpha=0.2, lw=2.0) # Arguments to matplotlib.patches.PathPatch()
patchlabel="Widget\nA") # Arguments to matplotlib.patches.PathPatch()
diagrams = sankey.finish()
diagrams[0].patch.set_facecolor('#37c959')
diagrams[0].texts[-1].set_color('r')
diagrams[0].text.set_fontweight('bold')
# Notice:
Expand All @@ -66,7 +64,7 @@
sankey = Sankey(ax=ax, unit=None)
sankey.add(flows=flows, label='one',
orientations=[-1, 1, 0, 1, 1, 1, -1, -1, 0])
sankey.add(flows=[-0.25, 0.15, 0.1], fc='#37c959', label='two',
sankey.add(flows=[-0.25, 0.15, 0.1], label='two',
orientations=[-1, -1, -1], prior=0, connect=(0, 0))
diagrams = sankey.finish()
diagrams[-1].patch.set_hatch('/')
Expand Down
5 changes: 2 additions & 3 deletions examples/api/sankey_demo_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
def side(sankey, n=1):
"""Generate a side chain."""
prior = len(sankey.diagrams)
colors = cycle(['orange', 'b', 'g', 'r', 'c', 'm', 'y'])
for i in range(0, 2*n, 2):
sankey.add(flows=[1, -1], orientations=[-1, -1],
patchlabel=str(prior + i), facecolor=next(colors),
patchlabel=str(prior + i),
prior=prior + i - 1, connect=(1, 0), alpha=0.5)
sankey.add(flows=[1, -1], orientations=[1, 1],
patchlabel=str(prior + i + 1), facecolor=next(colors),
patchlabel=str(prior + i + 1),
prior=prior + i, connect=(1, 0), alpha=0.5)


Expand Down
2 changes: 1 addition & 1 deletion examples/api/sankey_demo_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def put_labels(labels, positions, output=True):

patch, (intexts, outtexts) = sankey(ax, outputs=outputs,
outlabels=outlabels, inputs=inputs,
inlabels=None, fc='g', alpha=0.2)
inlabels=None)
outtexts[1].set_color('r')
outtexts[-1].set_fontweight('bold')

Expand Down
6 changes: 3 additions & 3 deletions examples/api/skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ def _set_lim_and_transforms(self):

# Plot the data using normal plotting functions, in this case using
# log scaling in Y, as dicatated by the typical meteorological plot
ax.semilogy(T, p, 'r')
ax.semilogy(Td, p, 'g')
ax.semilogy(T, p)
ax.semilogy(Td, p)

# An example of a slanted line at constant X
l = ax.axvline(0, color='b')
l = ax.axvline(0)

# Disables the log-formatting that comes with semilogy
ax.yaxis.set_major_formatter(ScalarFormatter())
Expand Down
2 changes: 1 addition & 1 deletion examples/lines_bars_and_markers/barh_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))

plt.barh(y_pos, performance, xerr=error, align='center', alpha=0.4)
plt.barh(y_pos, performance, xerr=error, align='center')
plt.yticks(y_pos, people)
plt.xlabel('Performance')
plt.title('How fast do you want to go today?')
Expand Down
5 changes: 2 additions & 3 deletions examples/lines_bars_and_markers/fill_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import numpy as np
import matplotlib.pyplot as plt


x = np.linspace(0, 1)
x = np.linspace(0, 1, 500)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)

plt.fill(x, y, 'r')
plt.fill(x, y)
plt.grid(True)
plt.show()
2 changes: 1 addition & 1 deletion examples/lines_bars_and_markers/fill_demo_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2 * np.pi, 100)
x = np.linspace(0, 2 * np.pi, 500)
y1 = np.sin(x)
y2 = np.sin(3 * x)
plt.fill(x, y1, 'b', x, y2, 'r', alpha=0.3)
Expand Down
2 changes: 1 addition & 1 deletion examples/lines_bars_and_markers/line_demo_dash_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import matplotlib.pyplot as plt


x = np.linspace(0, 10)
x = np.linspace(0, 10, 500)
line, = plt.plot(x, np.sin(x), '--', linewidth=2)

dashes = [10, 5, 100, 5] # 10 points on, 5 off, 100 on, 5 off
Expand Down
2 changes: 1 addition & 1 deletion examples/lines_bars_and_markers/line_styles_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def nice_repr(text):

linestyles = ['-', '--', '-.', ':']
for y, linestyle in enumerate(linestyles):
ax.text(-0.5, y, nice_repr(linestyle), **text_style)
ax.text(-0.1, y, nice_repr(linestyle), **text_style)
ax.plot(y * points, linestyle=linestyle, color=color, linewidth=3)
format_axes(ax)
ax.set_title('line styles')
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/lorenz_attractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def lorenz(x, y, z, s=10, r=28, b=2.667):
fig = plt.figure()
ax = fig.gca(projection='3d')

ax.plot(xs, ys, zs)
ax.plot(xs, ys, zs, lw=0.5)
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")
ax.set_zlabel("Z Axis")
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/surface3d_demo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
colors[x, y] = colortuple[(x + y) % len(colortuple)]

surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=colors,
linewidth=0, antialiased=False)
linewidth=0)

ax.set_zlim3d(-1, 1)
ax.w_zaxis.set_major_locator(LinearLocator(6))
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/trisurf3d_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, linewidth=0.2, antialiased=True)

plt.show()
11 changes: 5 additions & 6 deletions examples/pie_and_polar_charts/pie_demo_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')

plt.pie(sizes, explode=explode, labels=labels, colors=colors,
plt.pie(sizes, explode=explode, labels=labels,
autopct='%1.1f%%', shadow=True, startangle=90)
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
Expand All @@ -33,16 +32,16 @@
ax = fig.gca()
import numpy as np

ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors,
ax.pie(np.random.random(4), explode=explode, labels=labels,
autopct='%1.1f%%', shadow=True, startangle=90,
radius=0.25, center=(0, 0), frame=True)
ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors,
ax.pie(np.random.random(4), explode=explode, labels=labels,
autopct='%1.1f%%', shadow=True, startangle=90,
radius=0.25, center=(1, 1), frame=True)
ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors,
ax.pie(np.random.random(4), explode=explode, labels=labels,
autopct='%1.1f%%', shadow=True, startangle=90,
radius=0.25, center=(0, 1), frame=True)
ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors,
ax.pie(np.random.random(4), explode=explode, labels=labels,
autopct='%1.1f%%', shadow=True, startangle=90,
radius=0.25, center=(1, 0), frame=True)

Expand Down
4 changes: 2 additions & 2 deletions examples/pylab_examples/annotation_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction',
horizontalalignment='center', verticalalignment='center')
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

The 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]
Expand Down
Loading