FlowingData Forums » Data Visualization

Editing "R" pdf files in Illustrator

Started 5 months ago by johnstephenbyrne / 9 posts

  1. Hi guys.

    I have been playing around with the graphs in Nathan's great book Visualize This. However, I was disappointed to find that when I open the exported pdf graphs from R into Illustrator, my color swatches and a lot of the editing functions have disappeared. From searching on google, I have found that this is a problem with trying to edit pdf files in Illustrator. I tried opening them and then save as ai file but still the problem exists. How does Nathan get around this? Its not mentioned at all in the book.

    Thanks if anyone can help!

  2. Hm. Tools that appear do change depending on what you have selected. Does it change anything when you selection an object with the Direct Selection Tool?

  3. No, I think I have discovered that R outputs the graphs in RGB, but illustrator usually deals in CMYK. I have discovered that I can select the default RGB swatch to edit the items but the problem here is then that for printing I need the final document to be converted to CMYK.

    I have found that there is someway to set the color space of the pdf files in R but I can't understand the programming language sufficiently to do it myself. All I want to do is save my plot from R as a CMYK PDF file.

    Alternatively I know I could just finish my graph in Illustrator and then convert to a non editable raster file with the CMYK colorspace in photoshop but this seems not ideal.

    Any ideas?

  4. Ok Nathan, so I am beginning to get somewhere I think. I have learned that I can specify the parameters of the pdf output using the following argument for example using the hot dog contest example with code like this:
    pdf("hotdogs.pdf",colormodel="CMYK")
    This sets the output pdf to CMYK.
    However, when I go do my bar plot as before with e.g.:
    barplot(hotdogs$Dogs.eaten,names.arg=hotdogs$Year........etc......,col="red")
    then I get an error with the following:

    Warning messages:
    1: In rect(y1, x1, y2, x2, ...) : unknown 'colormodel', using 'srgb'
    2: In rect(y1, x1, y2, x2, ...) : unknown 'colormodel', using 'srgb'
    3: In axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...) :
    unknown 'colormodel', using 'srgb'
    4: In axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...) :
    unknown 'colormodel', using 'srgb'

    Can anyone help?

    This is really frustrating me! I do need to do high quality graphics but now it seems my efforts from the book might be wasted as I do need my final output to be in CMYK.

    Any ideas?

  5. colormodel = "cmyk" (note the lower case) should do the trick.

    Alternatively, you can convert in illustrator (File -> Document Color Mode -> CMYK). Just be sure to watch out for 4-color black.

  6. John, did m1arc00's tip help? I've having trouble reproducing the problem in Illustrator.

    What if you select all, and then in the options of the Color tab, you select CMYK?

    What happens when you open any other PDF file in Illustrator?

    Can you open the color swatch via the main Illustrator menu ("Windows")?

  7. Before I start, thanks everyone, the replies have come really quickly!

    Nathan, m1arc00's tip worked, I had it written as "CMYK" as opposed to "cmyk" and that has enabled me to save the file as a cmyk pdf.

    I still have the swatch problem tho. When editing other files, when I select an object, as usual, on top left in tool bar you get the fill and stroke color shown with the drop down menu arrow beside them which brings up a panel of swatches to change the color. With the pdf files from R, it shows the color and stroke of the object but when I hit the drop down arrow, the panel is blank excel for the option of no stroke/fill or something called [Registration]. Now I can select one of the sub menu options on these panels to select for example the default CMYK swatch which then opens in a floating window and I can use this but still it doesn't appear in the drop down panel.

    I hope I am explaining this clearly!

    It is bizarre! I can't find an explanation! Anyway it is I guess an acceptable work around as I do love the combination of R and Illustrator. While R is difficult to get used to, I find it is actually more logical in format for producing graphs than for example excel etc.

    BTW again, here far away in Ireland I am delighted to have found your book, it has opened up a doorway for my stats!

  8. Ok I finally sorted it!

    I think it is due to the fact that a pdf saved from R has no color space built in and thus AI will treat it as thus when opened.

    So, anyway. I save the bar plot from R using the command pdf("bar plot.pdf",colormodel="cmyk"), specifying CMYK as I have done there. Then instead of opening the file in AI, I open a new CMYK document with all the lovely swatches appearing there. I then open the bar plot.pdf in AI and copy the bar plot into my new document and hey presto, my swatches remain!

    You have no idea of the magnitude of my sigh of relief when this worked!

    Thanks for the tips in getting me there! I have no idea why it works this way, perhaps its the version I am using, CS4?

    For some reason, I can only do this if I save the file with the pdf() command as opposed to going to the file menu and hitting "Save as".

    I was beginning to lose hope for a while!

  9. Glad it worked out!


Reply

You must log in to post.

About this Topic

Tags

No tags yet.