question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rasterized colorbars in PDFs are not recognized by Adobe Illustrator

See original GitHub issue

When I try to edit a PDF generated by plotnine in Illustrator, I get an An unknown imaging construct was encountered. warning if there is a continuous color scale in the plot (e.g. gradient). This also makes the color legend uneditable. I was wondering why this might be happening and so I made some experiments with matplotlib and also ggplot2 in R.

This is a simple example to generate such a plot:

from plotnine import *
import numpy as np

x = np.linspace(0, 1, 10)
g = qplot(x, x, color=x, geom='point')
ggsave(g, 'ggplot-python.pdf')

Here is how it looks like in Illustrator, big X sign indicates the “unknown imaging construct” (for some reason it covers the entire image but it is actually only due to the color legend):

image

When I move the legend around:

image

However a simple gradient produced directly by matplotlib renders fine and is editable:

f, ax = plt.subplots(figsize=(4,0.5))
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))
ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap('viridis'))
f.savefig('matplotlib.pdf')

image

Last, I tried the R equivalent of the first code:

library(ggplot2)

x = seq(0, 1, by=0.1)
g = qplot(x, x, color=x)

ggsave('ggplot-R.pdf')

Color bar in this PDF looks perfectly fine and there is no warning at all:

image

I know that asking for a fix that affects only (and is reproducible only with) Illustrator which is a proprietary software, is not very meaningful, given that plotnine is a great free software. But I just wanted to ask if there is anything weird about the PDFs with gradients produced by plotnine, or can we make them more “R-like” so that they are easier to edit.

Cheers.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
has2k1commented, Jul 23, 2020

Thanks for trying to get to the bottom of this. This issue is like bad xml/html markup where some tag/attribute is badly encapsulated. I think I will wait and see want comes from the matplotlib bug report.

0reactions
has2k1commented, Mar 28, 2022

I recall to have looked at how the colorbar was implemented in Matplotlib, it was quite involved but I noticed that Quadmesh was used and so I built a solution using Quadmesh. I do not recall even thinking about PolyCollection!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adobe PDF options | Illustrator
Adobe PDF options are divided into categories. Changing any option causes the name of the preset to change to Custom.
Read more >
Detail lost when exported as PDF/Rasterized - 8727517
Im wondering is there a way to export the file and retain this detail OR alternatively set illustrator up so that it I...
Read more >
Advanced PDF print settings - Acrobat Pro - Adobe Support
Set advanced print options (Acrobat Standard). The Advanced Print Setup dialog box is available for PostScript and non-PostScript printers.
Read more >
How to add printer's marks and bleeds in Illustrator
Choose File > Print. · Select Marks & Bleed on the left side of the Print dialog box. · Select the kinds of...
Read more >
Saving pdf will make rasterized image blank / white / invisible.
I have to create the file with illustrator because theres a spot color that needs to be on a layer so my plotter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found