Skip to content
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

Colorbar edges are different in PDF backend #1450

Merged

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Nov 5, 2012

This is a reopening of #1444, since it still hasn't found a satisfactory solution.

In a message on matplotlib-users from Andrew Dawson:

Hi all,

I just noticed that colorbar edges are drawn in white when output in PDF and black when output in PNG. A small test script is attached along with the output to show the difference.

I'd be interested in knowing if others can reproduce this? I'm using mpl-1.3.x (updated 5 minutes ago) on 64-bit Ubuntu 12.04.

Cheers,
Andrew

import matplotlib.pyplot as plt
import numpy as np

# dummy data
x = y = np.linspace(-np.pi, np.pi, 50)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(2.*Y)

# draw a filled contour plot and add a colorbar with drawedges turned on
contours = plt.contourf(x, y, Z)
cb = plt.colorbar(orientation='horizontal', drawedges=True)

# turn off tick marks so the edges can be seen
for tick in cb.ax.get_xticklines() + cb.ax.get_yticklines():
    tick.set_visible(False)

# save as a PDF and a PNG
plt.savefig('test.pdf')
plt.savefig('test.png')

@mdboom
Copy link
Member Author

mdboom commented Nov 5, 2012

In my original solution, I had forgotten that a GraphicsContextPdf actually as push and pop, and that's really what should have been used to save/restore the graphics state. This seems to work now, and all tests are passing. If anyone else wants to test this out, that would be great -- and I'm sure Travis will give us some results momentarily.

@dmcdougall
Copy link
Member

I tested this out. It works for me, too! Good work @mdboom

@dmcdougall
Copy link
Member

@mdboom Can you squash this down to a single commit?

@mdboom
Copy link
Member Author

mdboom commented Nov 6, 2012

Thanks. Squashed.

dmcdougall added a commit that referenced this pull request Nov 6, 2012
Colorbar edges are different in PDF backend
@dmcdougall dmcdougall merged commit 85a6ccf into matplotlib:v1.2.x Nov 6, 2012
@dmcdougall
Copy link
Member

Thanks.

@mdboom mdboom deleted the fix_pdf_path_collection_state2 branch March 3, 2015 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants