Skip to content

Markers in plot and scatter ignore antialiased=False setting #10825

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

Open
ImportanceOfBeingErnest opened this issue Mar 17, 2018 · 5 comments
Open
Labels
keep Items to be ignored by the “Stale” Github Action

Comments

@ImportanceOfBeingErnest
Copy link
Member

Bug report

Bug summary

Markers in line plots and scatter plots cannot be created without antialiasing. The argument antialiased=False is ignored. The scatter dots are still antialiased when calling

plt.scatter(..., antialiased=False)
plt.plot(..., marker="o", antialiased=False)

The line of a line plot as well as a Circle are however obeying to turning the antialiasing off.

Code for reproduction

I will provide a not-so-minimal example here, but which allows to directly observe the difference between antialiased=True and antialiased=False within matplotlib and can potentially directly be used as a test for the issue.

The following produces a two-part image, each with a line, a circle (red, nose) and a scatter and a line plot with marker (orange, eyes). In the left part all artists are being given the antialiased=True, in the right part antialiased=False.

import io
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt

fig, axes = plt.subplots(ncols=2, figsize=(.5,.25), dpi=72)
fig.subplots_adjust(0,0,1,1,0,0)

## Produce a line plot, a scatter and a circle
## Set antialiased=True, False to observe the difference.
for aa,ax in zip([True,False],axes):
    ax.axis([0,3,0,3])
    ax.axis("off")
    ax.plot([.8,1.2,1.8,2.2],[1,.6,.6,1], antialiased=aa)
    
    ax.scatter([2],[2],s=16,edgecolor="k",facecolor="C1", antialiased=aa)
    ax.plot([1],[2],marker="o",ms=4,mec="k",mfc="C1", antialiased=aa)
    c = plt.Circle((1.5,1.5), radius=0.35, edgecolor="k",
                   facecolor="C3", antialiased=aa)
    ax.add_patch(c)

buf = io.BytesIO()
fig.savefig(buf)
#fig.savefig("test"+str(matplotlib.get_backend())+".png")
plt.close()

## Read and show the produced images from above as imshow
fig, (ax,ax2) = plt.subplots(ncols=2, figsize=(5,2.6))
buf.seek(0)
im = plt.imread(buf)
ax.imshow(im[:,:im.shape[1]//2], origin="upper")
ax2.imshow(im[:,im.shape[1]//2:], origin="upper")
ax.set_title("antialiased=True")
ax2.set_title("antialiased=False")
fig.suptitle(matplotlib.get_backend())
fig.savefig("antialiased"+str(matplotlib.get_backend())+".png")
plt.show()

Actual outcome

antialiasedtkagg

Expected outcome

In the right image, we would expect the orange dots to consist only of black and orange pixels, similar to the red circle (the nose).

Matplotlib version

  • Operating system: Windows 8.1
  • Matplotlib version: 2.2
  • Matplotlib backend: TkAgg, same with Qt4Agg
  • Python version: 2.7.10
@timhoffm
Copy link
Member

timhoffm commented Mar 18, 2018

Not a backend expert, but it looks like RendererAgg::draw_markers does not check GCAgg.isaa and always uses the antiliased renderer.

@jklymak
Copy link
Member

jklymak commented Mar 27, 2018

Closing due to #10833

@jklymak jklymak closed this as completed Mar 27, 2018
@QuLogic
Copy link
Member

QuLogic commented Mar 27, 2018

Did you check that it's fixed? That PR is not necessarily supposed to fix it.

@anntzer anntzer reopened this Mar 27, 2018
@jklymak
Copy link
Member

jklymak commented Mar 27, 2018

Sorry! 🐑

@jklymak jklymak added this to the v3.0 milestone Mar 27, 2018
@tacaswell tacaswell modified the milestones: v3.0, v3.1 Aug 11, 2018
@tacaswell tacaswell modified the milestones: v3.1.0, v3.2.0 Mar 18, 2019
@tacaswell tacaswell modified the milestones: v3.2.0, needs sorting Sep 10, 2019
@github-actions
Copy link

github-actions bot commented May 2, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label May 2, 2023
@anntzer anntzer added the keep Items to be ignored by the “Stale” Github Action label May 2, 2023
@rcomer rcomer removed the status: inactive Marked by the “Stale” Github Action label May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep Items to be ignored by the “Stale” Github Action
Projects
None yet
Development

No branches or pull requests

7 participants