forked from Sharpie/RTikZDevice
-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Following this linked below, I would love to use tikzdevice without it creating ANY png. This means also for using "gradient scales".
Here is an example:
if (!require("pacman")) install.packages("pacman")
pacman::p_load('tidyverse' ,
'tikzDevice', 'tinytex')
#forplotting to LATEX
options(tikzDocumentDeclaration = "\\documentclass[12pt]{article}")
set.seed(1)
df <- data.frame(
x = runif(100),
y = runif(100),
z1 = rnorm(100),
z2 = abs(rnorm(100))
)
corrs <- round(stats::cor(df , use = "everything" ), 2)
#to plot the upper triangle set the upper triangle to NA
corrs[lower.tri(corrs)] <- NA
dfplot <- reshape2::melt(corrs, na.rm = TRUE)
corrplot <- ggplot(data = dfplot, aes(Var2, Var1, fill = value))+
geom_tile(color = "white")+
scale_fill_gradient2(low = "darkblue", high = "orange", mid = "white", space = "Lab",
midpoint = 0, limit = c(-2,2),
name="Pearson's Correl. Cofff.")+
geom_text(aes(Var2, Var1, label = value), color = "black") +
scale_y_discrete(position = "right" ) +
guides(fill = guide_colorbar(barwidth = 8, barheight = 1,
title.position = "top", title.hjust = 0.5))+
theme_minimal() +
theme(axis.title = element_blank(),
legend.position = c(0.2, 0.85 ),
legend.location = "plot",
legend.direction = "horizontal" ) +
coord_fixed()
corrplot
tikz('corrplot.tex', width = 5, height = 5,
standAlone=TRUE, sanitize = TRUE)
print(corrplot)
dev.off()This always generates a nice LaTeX file, but also a figure called "corrplot_ras1.png".
My question: Is there any way I could circumvent this PNG generation process?
Thank you!
@bridgeovertroubledhuman Could you create a new issue referencing this? Thanks!
Originally posted by @rstub in #121 (comment)
Metadata
Metadata
Assignees
Labels
No labels