-
Notifications
You must be signed in to change notification settings - Fork 5
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
ggplot aestethics in ts_plot and issue saving plot #6
Comments
Hi Paula, Thanks for the bug-report. Try rather ggOceanPlots. It is more updated (and development of PlotSvalbard has ended). It seems that the marginal plot code in the library(ggOceanPlots)
library(ggplot2)
#Setting some graphical details
color_cross <- c("Inshore" = "#6C809A", "Midshelf" = "#FAAA8D", "Offshore" = "#98473E")
#Create data
CTD <- data.frame(Habitat = c("Inshore", "Inshore", "Inshore", "Midshelf", "Midshelf","Midshelf", "Offshore",
"Offshore","Offshore"),
Depth = c(1, 2, 3,1, 2, 3,1, 2, 3 ),
Temp = c (23, 22.5, 21, 22, 22, 24.5, 24, 25, 24.5),
Sal = c(35.5, 35.8, 35, 34.5, 34.6, 34.6, 34, 34.2, 34))
png("test.png", height = 22, width = 25, unit = "cm", res = 300)
ts_plot(CTD,
temp_col = "Temp",
sal_col = "Sal",
WM = NULL,
color_wmpoly = NULL,
xlim = c(33,36),
ylim = c(20,26),
color = "Habitat",
zoom = TRUE,
nlevels = 1,
color_isopyc = "grey90",
symbol_shape = 16,
symbol_size = 3,
symbol_alpha = 0.6,
color_scale = color_cross,
color_var_name = NULL,
margin_distr = TRUE, #this one shows Kernel density
margin_width = 0.15,
margin_height = 0.2,
plot_data = TRUE,
base_size = 10
)
dev.off() ts <- ts_plot(CTD,
temp_col = "Temp",
sal_col = "Sal",
WM = NULL,
color_wmpoly = NULL,
xlim = c(33,36),
ylim = c(20,26),
color = "Habitat",
zoom = TRUE,
nlevels = 1,
color_isopyc = "grey90",
symbol_shape = 16,
symbol_size = 3,
symbol_alpha = 0.6,
color_scale = color_cross,
color_var_name = NULL,
margin_distr = FALSE, #this one shows Kernel density
margin_width = 0.15,
margin_height = 0.2,
plot_data = TRUE,
base_size = 10) +
ggplot2::theme(axis.title = element_text(size = 20, color = "blue"))
ggsave(ts, file = "test2.png",
height = 22, width = 25, unit = "cm" ) # Works |
Hi Mikko, So sorry for my late reply! Thank you, I'm now using ggOceanPlots. I want to keep the Kernel density graphs so unfortunately, I can't set the marginal distributions off. However, I just changed the letter sizes with base_size and that's good enough for my figures. Thanks again! Paula |
Thanks. Let's just keep this open as a reminder that I'll need to look into this one day when I have time. |
Hi Mikko,
Thank you for this package! I'm able to obtain the T-S plot successfully, but I'm now trying to change the size and colour of axis titles, etc, and I'm not able to do this. I've tried adding this change inside ts_plot and outside, but no success. Is this possible?
Another issue is that I'm trying to save the plot using ggsave, but instead I obtained an empty plot. I can save other plots using the exact same code, so I guess it should be an issue with this function. See an example below.
Thank you in advance!
Paula
library(PlotSvalbard)
library(here)
#Setting some graphical details
color_cross <- c("Inshore" = "#6C809A", "Midshelf" = "#FAAA8D", "Offshore" = "#98473E")
#Create data
CTD <- data.frame(Habitat = c("Inshore", "Inshore", "Inshore", "Midshelf", "Midshelf","Midshelf", "Offshore",
"Offshore","Offshore"),
Depth = c(1, 2, 3,1, 2, 3,1, 2, 3 ),
Temp = c (23, 22.5, 21, 22, 22, 24.5, 24, 25, 24.5),
Sal = c(35.5, 35.8, 35, 34.5, 34.6, 34.6, 34, 34.2, 34))
#Plot TS
ts <- ts_plot( CTD,
temp_col = "Temp",
sal_col = "Sal",
WM = NULL,
color_wmpoly = NULL,
xlim = c(33,36),
ylim = c(20,26),
color = "Habitat",
zoom = TRUE,
nlevels = 1,
color_isopyc = "grey90",
symbol_shape = 16,
symbol_size = 3,
symbol_alpha = 0.6,
color_scale = color_cross,
color_var_name = NULL,
margin_distr = TRUE, #this one shows Kernel density
margin_width = 0.15,
margin_height = 0.2,
plot_data = TRUE,
base_size = 10
)
ggsave(ts, file=here::here("graphs", "ts_cross.png"),
height = 22, width = 25, unit = "cm" ) #Doesn't work
The text was updated successfully, but these errors were encountered: