Skip to content

Plot Colorbar in axes_grid1 with pcolormesh #630

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

Merged
merged 1 commit into from
Jan 1, 2012

Conversation

jenshnielsen
Copy link
Member

This is identical to the standard colorbar and removes artifacts (white stripes)
in the pdf version of the ImageGrid plot.

The following example should illustrate the difference.

from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid,make_axes_locatable

F = plt.figure()
grid = ImageGrid(F, 111, # similar to subplot(111)
                 nrows_ncols = (2, 2),
                 axes_pad = 0.1,
                 add_all=True,
                 label_mode = "L",
                 share_all = True,
                 cbar_mode = "single",
                  )
data = np.arange(100).reshape(10,10)
for a in range(4):
    ax = grid[a]
    im = ax.imshow(data,interpolation='none',origin='lower')
v = grid.cbar_axes[0].colorbar(im)

plt.savefig('test_imagegrid.pdf')

Examples of the figures using current v1.1.x branch without and with the pcolormesh.

Before:
http://ubuntuone.com/5p9IYAFbFj9bbmN4A1dfo9
After:
http://ubuntuone.com/18vD21xtiQuVTFy96QVNOS

This is identical to the standard colorbar and removes artifacts
in the pdf version of the plot.
@Carreau
Copy link
Contributor

Carreau commented Dec 16, 2011

Note that depending of the pdf reader you use the two above link might be pixel perfect corresponding images.
but I agree that the pdf reader which showed strips, it is fixed.

@jenshnielsen
Copy link
Member Author

I did not investigate that.
But yes thats right. In adobe reader X they are rendered identical while they are different
in Okular, Evince and Xpdf. (Ubuntu 11.10)

@WeatherGod
Copy link
Member

The white lines are a known issue and is entirely dependent upon the pdf viewers. So, the question that remains is, even though it is not a bug on our part, should we change to pcolormesh so that our users get a better quality product, or should we prod some of these projects to fix their viewers? Or both?

@jenshnielsen
Copy link
Member Author

Yes I see. This it would indicate that the bug is in Cairo or Poppler since all 3 viewers use Poppler
and Poppler uses Cairo to render vector graphics.

In any case it seem strange that axisgrid1 method produces the white lines while the standard colorbar
does not. For a normal user this would indicate a bug in the axisgrid1 implementation. Also if one tries to add a normal colorbar to the figure using plt.colorbar() then this results in both a standard misplaced colorbar and another colorbar
on top of the axisgrid1 colorbar. Both of these have white stripes but shifted to make it look like the artifacts are gone.

efiring added a commit that referenced this pull request Jan 1, 2012
Plot Colorbar in axes_grid1 with pcolormesh
@efiring efiring merged commit d23f721 into matplotlib:v1.1.x Jan 1, 2012
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.

4 participants