ggplot2 pdf import in Adobe Illustrator missing font AdobePiStd
Although changing the fonts used by AI works well, an alternative is to restrict ggplot2 from using Dingbats in the first place by adding the argument 'useDingbats' to your ggsave command eg:
ggsave(plot=p,height=6,width=6,dpi=200, filename="~/example.pdf", useDingbats=FALSE)
Importing Dotplot from R to Adobe Illustrator causes dot shapes to change
If you can share your code, it might help. However, I faced absolutely no problem while viewing a dotplot in Illustrator. Used the following to generate the dotplot:
library(ggplot2)
ggplot(mtcars, aes(x = mpg)) + geom_dotplot()
In the Plots viewer, I saved it as a pdf and the opened it in Illustrator (CC 2015).
ggplot2: theme_set, pdf export, and Illustrator having difficulties
size=NA
in axis.line = element_line(colour=gridc, size=NA, linetype="solid")
cause the problem.
Use element_blank
if you do not want to show the line.
This may not be a bug, but I suggest you to file this problem on github: https://github.com/hadley/ggplot2/issues
In future, ggplot2 may have ability to check the validity of parameters.
ggplot2 geom_point 50000 points - output to pdf - need to open in Illustrator
Have you tried svg()
:
x<-runif(50000)
y<-runif(50000)
qplot(x,y,alpha=0.1)
svg("x.svg")
qplot(x,y,alpha=0.1)
dev.off()
Modifying fonts in ggplot2
Sorted out my query with fairly minimal hassle. It was a two-step solution that I wouldn't have arrived at without following the advice of the members who responded.
To change the ggplot text defaults, I adapted the code that Brandon referred me to at:
http://johndunavent.com/combined-line-and-bar-chart-ggplot2
Where John Dunavent creates a function, theme_min, that can be edited to provide the default options for a ggplot, including using fonts imported from Windows with the windowsFonts command. My adaptation of his code looks like this:
theme_min = function (size=10, font=NA, face='plain',
panelColor=backgroundColor, axisColor='#999999',
gridColor=gridLinesColor, textColor='black')
{
theme_text = function(...)
ggplot2::theme_text(family=font, face=face, colour=textColor,
size=size, ...)
opts(
axis.text.x = theme_text(),
axis.text.y = theme_text(),
axis.line = theme_blank(),
axis.ticks = theme_segment(colour=axisColor, size=0.25),
panel.border = theme_rect(colour=backgroundColor),
legend.background = theme_blank(),
legend.key = theme_blank(),
legend.key.size = unit(1.5, 'lines'),
legend.text = theme_text(hjust=0),
legend.title = theme_text(hjust=0),
panel.background = theme_rect(fill=panelColor, colour=NA),
panel.grid.major = theme_line(colour=gridColor, size=0.33),
panel.grid.minor = theme_blank(),
strip.background = theme_rect(fill=NA, colour=NA),
strip.text.x = theme_text(hjust=0),
strip.text.y = theme_text(angle=-90),
plot.title = theme_text(hjust=0),
plot.margin = unit(c(0.1, 0.1, 0.1, 0.1), 'lines'))
}
##Create a custom font type. Could be 'F', 'TEST', whatever
windowsFonts(F = windowsFont('Wide Latin'))
##and insert this line of code into the original code I list above:
+ theme_min(font='F', size=10)
Awkwardly, there is no way (that I found) to generically modify the font settings for geom_text objects before a plot is created. James' solution above worked perfectly for this, though. Instead of using a standard font, I set fontfamily="F" to bring in the custom font that I selected in theme_min(), i.e.:
grid.gedit("GRID.text",gp=gpar(fontfamily="F"))
Hopefully this is useful to any other users looking to modify fonts on their graphs.
Cheers to all who helped me sort this out!
Aaron
Fonts in R plots
A list of fonts is available to the pdf()
command, like this:
> names(pdfFonts())
[1] "serif" "sans" "mono"
[4] "AvantGarde" "Bookman" "Courier"
[7] "Helvetica" "Helvetica-Narrow" "NewCenturySchoolbook"
[10] "Palatino" "Times" "URWGothic"
... etc ...
To use when creating a PDF, for example:
> pdf(file="plot.pdf",family="Palatino", pointsize=16, width=16,height=10)
Related Topics
Scoping of Variables in Aes(...) Inside a Function in Ggplot
Shiny Rcharts Multiple Chart Output
Plot Separate Years on a Common Day-Month Scale
R Shiny Loop to Display Multiple Plots
Generally Disable Dimension Dropping for Matrices
How to Automatically Load Data in an R Package
How to Change Name of Factor Levels
How to Add Legend to Geom_Smooth in Ggplot in R
Max and Min Functions That Are Similar to Colmeans
1-Dimensional Matrix Is Changed to a Vector in R
"Object Not Found" Error Within a User Defined Function, Eval() Function
Using User-Defined "For Loop" Function to Construct a Data Frame
Removing One Table from Another in R
R - Unable to Install R Packages - Cannot Open the Connection
R Shiny Ggplot Bar and Line Charts with Dynamic Variable Selection and Y Axis to Be Percentages
How to Read a Text File into Gnu R with a Multiple-Byte Separator