Skip to content

Markers are offset when 'facecolor' or 'edgecolor' are set to 'none' when plotting data #12645

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

Closed
pdulab opened this issue Oct 26, 2018 · 1 comment

Comments

@pdulab
Copy link

pdulab commented Oct 26, 2018

Bug report

When plotting data with either 'scatter' or 'plot', the markers are slightly offset when the 'facecolor' or 'edgecolor' are set to 'none'.
It seems to happen only with some markers: ". o v ^ 8 p P * h H X x". I could not verify for '1 2 3 4'. Some markers are always offset (different issue maybe): '+ | _'

Code for reproduction

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(12, 12))

ax = plt.axes()

#Marker
m = '8'

#Error when 'none' is chosen as 'facecolor'
ax.scatter(1,1,marker=m,edgecolor= 'red',facecolor='none') #Marker offset
ax.scatter(1,2,marker=m,edgecolor='red',facecolor='black') #No marker offset

#Error when 'none' is chosen as 'edgecolor'
ax.scatter(2,1,marker=m,edgecolor='none', facecolor='red') #Maker offset
ax.scatter(2,2,marker=m,edgecolor='black',facecolor='red') #No marker offset

#Grid, to see the offset
ax.grid()

You can also see the misalignement when plotting to point on top of each other (therefore the problem does not come from adding the grid). This is most apparent when the top one is smaller:

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(12, 12))

ax = plt.axes()

#Marker
m = '8'

#Same size markers
#It looks like an eclipse
ax.scatter(0,0,marker=m,edgecolor='red', facecolor='red')
ax.scatter(0,0,marker=m,edgecolor='none',facecolor='black')

#Different size markers
ax.scatter(0.5,0.5,s=50,marker=m,edgecolor='red', facecolor='red')
ax.scatter(0.5,0.5,s=30,marker=m,edgecolor='none',facecolor='black')

Expected outcome
The markers should be aligned with the grid or on top of each other.

Matplotlib version

  • Operating system: Win 10
  • Matplotlib version: 3.0.1(but also present in 2.1)
  • Matplotlib backend: Qt5Agg
  • Python version: 3.6.3
@jklymak
Copy link
Member

jklymak commented Oct 26, 2018

Corssref #11836, #7233, #8533

This is a known issue, and I'm going to close as covered elsewhere.

Markers are placed to the nearest pixel, supposedly for speed. If you need sub-pixel accuracy, use PDF or more pixels. You could also try out the third-party library that will hopefully make it into matplotlib one of these days: https://github.com/anntzer/mplcairo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants