Reputation: 919
When drawing points with very close values, sometimes points with different values seem to have the same value. On picture below, all six points have different ordinate values, yet it seems as if points 2,3 and points 4,5,6 have the same value.
I am aware that this is the problem of resolution (which I cannot increase for reasons not elaborated here). Still, is there any possibility to tell matplotlib
to draw these points more precisely?
MWE:
import matplotlib
from matplotlib import pyplot as plt
coor = [[0.5,0.525,0.55,0.575,0.6,0.625],[0.5,0.501,0.502,0.503,0.504,0.505]]
fig = plt.figure(figsize=(3.5,3.5))
plts=fig.add_subplot(1,1,1)
fig.subplots_adjust(left=0.01, right=0.99, bottom=0.01, top=0.99, hspace=0, wspace=0)
plts.set_xlim([0,1])
plts.set_ylim([0,1])
plts.get_xaxis().set_visible(False)
plts.get_yaxis().set_visible(False)
grph = plts.scatter(coor[0],coor[1],facecolor='k',marker='o',lw=0,s=25)
fig.savefig('test.png', bbox_inches='tight', dpi=100)
Upvotes: 3
Views: 199
Reputation: 919
This is actually the algorithm problem that appeared with mathlab
version 1.4. Read details here:
https://github.com/matplotlib/matplotlib/issues/8533
https://github.com/matplotlib/matplotlib/issues/7233
https://github.com/matplotlib/matplotlib/issues/7262
Upvotes: 0
Reputation: 339170
The problem comes from the resoltion of 100 dpi. Since the dots' positions need to be multiples of 1 pixel, their positions look discretized.
You can of course increase the dpi when saving the picture. The following is the original picture, saved with 100 dpi, showing the undesired behaviour.
The following is the picture saved with 300 dpi and afterwards downsampled to the same size as the original picture.
If you choose figure size such that
figsize*saved_dpi/desired_dpi == integer
the result would even better; but you would need to refrain from using bbox_inches='tight'
then.
Upvotes: 3