Skip to content

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

Open

Description

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

Activity

  1. timhoffm commented on Mar 18, 2018

    @timhoffm
    Member

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

  2. jklymak commented on Mar 27, 2018

    @jklymak
    Member

    Closing due to #10833

  3. QuLogic commented on Mar 27, 2018

    @QuLogic
    Member

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

  4. jklymak commented on Mar 27, 2018

    @jklymak
    Member

    Sorry! 🐑

  5. added this to the milestone on Mar 27, 2018
  6. modified the milestones: v3.0, v3.1 on Aug 11, 2018
  7. modified the milestones: v3.1.0, v3.2.0 on Mar 18, 2019
  8. github-actions commented on May 2, 2023

    @github-actions

    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!

  9. added
    keepItems to be ignored by the “Stale” Github Action
    on May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions