Issue 1:
It would be great if we can have either a jitter command or a jitter flag in scatter.

I'm refering to something like ggplot2's geom_jitter.

A basic solution:

def rand_jitter(arr):
stdev = arr.max()/100.
return arr + np.random.randn(len(arr)) * stdev

def jitter(x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, hold=None, **kwargs):
return scatter(rand_jitter(x), rand_jitter(y), s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, hold=None, **kwargs)

Of course the definition of stdev needs to be better, this will only work for some cases.

The idea is from this SoF post.

Issue 2:
Bug report

Bug summary

Changing the figure's dpi via fig.set_dpi() does not have the desired effect. There are strange things happening when saving or showing the figure as detailed below.

Bug 1 - saving

In the following a figure with dpi=200 should be saved in all 3 cases.

import matplotlib.pyplot as plt

get_img_size = lambda path: print(plt.imread(path).shape)

fig1, ax1 = plt.subplots(dpi=200)
ax1.plot([1,2])
fig1.savefig("fig1.png")
get_img_size("fig1.png")

fig2, ax2 = plt.subplots(dpi=100)
ax2.plot([1,2])
fig2.savefig("fig2.png", dpi=200)
get_img_size("fig2.png")

fig3, ax3 = plt.subplots(dpi=100)
ax3.plot([1,2])
fig3.set_dpi(200)
fig3.savefig("fig3.png", dpi="figure")
get_img_size("fig3.png")

Qt5Agg

The outcome using the Qt5Agg backend of this is

(960, 1280, 4)
(960, 1280, 4)
(480, 640, 4)

i.e. in the first two cases we get the expected 200 dpi figure. In the last case, where the figure dpi is set via fig.set_dpi it seems to be ignored and the output image has a dpi of 100.

TkAgg

Using the TkAgg backend, the saved figures are as expected ((960, 1280, 4) in all cases.)

Bug 2 - showing

In the following we would expect to get two identical figures shown, both with dpi=100 and 640x480 pixels large.

plt.close("all")

fig1, ax1 = plt.subplots(num="expected", dpi=100)
ax1.plot([1,2])

fig3, ax3 = plt.subplots(num="buggy", dpi=50)
ax3.plot([1,2])
fig3.set_dpi(100)
print(fig3.get_dpi())
fig3.savefig("fig3a.png", dpi="figure")
print(fig3.get_dpi())
plt.show()
print(fig3.get_dpi())

Qt5Agg

The output (with Qt5Agg) is the following:

100
100
50

The printed dpi is correctly 100 before showing the figure. After showing, it prints 50. The shown figures have both the correct size, but the figure where dpi is set via fig.set_dpi has narrower linewidth and smaller fontsize. It looks exaclty like a figure that would have been expected for dpi=50, just with the wrong pixel size.

TkAgg

Using TkAgg backend, the output is correctly printed as 100 in all cases, but the shown figures differ in size; the left (expected) figure is 640x480 pixels, while the right figure is 640x445 pixels.

Matplotlib version

Operating system: Windows 8.1

Matplotlib version: master (2.2.2.post1088.dev0+g9ec4b95d6)

Matplotlib backend: Qt5Agg & TkAgg (see text)

Python version: 3.6.4

Running the same with matplotlib 2.0.2 (all other versions the same) I get

Qt5Agg, saving: (960, 1280, 4), (960, 1280, 4), (480, 640, 4) - same bug as above with master.

Qt5Agg, showing 100, 100, 100 - printed dpi are all the same, shown figures are the same.

TkAgg, saving: (960, 1280, 4) in all cases. - same expected behaviour as above.

TkAgg, showing 100, 100, 100 - printed dpi are all the same, shown figures differ in same manner as above.