Closed dlebauer closed 9 years ago
@dlebauer Hi David, thanks for posting. I am taking a look at this today. Do similar type functions exist for plotting the variance decomposition and sensitivity plots, where I want the prior/posterior results on the same plot as well?
This functionality should exist - have you looked at the code for these functions?
I haven't looked at the code that provides the SA and VD plots in detail, but did you have a script that uses the existing SA and VD plot functions in such a way to produce multiple results on the same plot? For example, what you have provided above should produce Figure 4 within your 2013 Ecological Monographs paper. I am looking to re-create Figures 6 and Figures 7 within your Monographs paper as well.
In this directory: https://github.com/dlebauer/pecan-archives/blob/master/manuscript/
the priors plots are in priors.Rnw
and the rest of the results are in results.Rnw
(btw this repository is a mirror of the archive: https://www.ideals.illinois.edu/handle/2142/34655)
@dlebauer The link appears to be broken for: https://github.com/wic/ggplot2/wiki/New-theme-system. It seems like the function works even with the deprecated version. Do I lose functionality without implementing the theme update?
@braczka I updated the link to the new ggplot2 theme system guide
Do I lose functionality without implementing the theme update?
Read the guide and let me know.
Sorry, I was making that out to be a lot harder than it was. I didn't realize that most of the functionality to plot multiple results for the SA and VD plots was built into the function itself (plot.variance.decomposition and plot.sensitivities) Thank you for being patient.
@dlebauer When using the plot.variance.decomposition() function for multiple sensitivity results I have been getting the following error: "Error: Incompatible lengths for set aesthetics: size" The two 'sensitivity.results.Rdata' output I used contain the same variables and quantile evaluations etc. I call the function as follows:
vd.plots <- plot.variance.decomposition(prior.sensitivity.results$variance.decomposition.output, post.sensitivity.results$variance.decomposition.output) pdf(file.path('~/code_stash/plot_theme_update', "variancedecomposition.pdf"), width = 11, height = 8) do.call(grid.arrange, c(vd.plots, ncol = 4)) dev.off()
As a side note, using the same 'sensitivity.results.Rdata' with the plot.senstivities() functions seems to work OK, as both response curves are displayed on the same figure correctly.
@braczka What have you tried in the way of debugging? Have you started updating the syntax as previously discussed?
@dlebauer For the plot.trait() function I did update the syntax because it gave deprecation warnings. I did not update the syntax within plot.variance.decomposition() because I didn't get any warnings. I am taking a closer look now. It looks like within the plot.variance.decomposition() it calls upon ggplot and not ggplot2.....
@dlebauer Did some more troubleshooting. Found that the error: Incompatible lengths for set aesthetics: size
comes from the variable vd.plots$trait.plot
. I am fairly sure the problem is occurring because of the size setting within vd.plots$trait.plot$layers
as follows:
mapping: x = points, y = 1, label = trait.labels, hjust = 1
geom_text: parse = FALSE, size = numeric(0)
stat_identity:
position_identity: (width = NULL, height = NULL)
Instances where the variance decomposition plot is created successfully the size = 4.6667
. Still looking at this, not sure how to correct it.
I see where the size
is assigned in the code to `size = fontsize$axis/3`` . Let me see if changing this fixes things.
@dlebauer Manually assigning the size gets rid of the incompatible lengths set aesthetics:size
, and a vd plot is created but NOT with multiple data sets being passed in. It seems the functionality for plot.variance.decomposition()
only works for 1 data set at a time, not for two data sets as:
vd.plots <- plot.variance.decomposition(prior.sensitivity.results$variance.decomposition.output,
post.sensitivity.results$variance.decomposition.output)
pdf(file.path('~/code_stash/plot_theme_update', "variancedecomposition.pdf"),
width = 11, height = 8)
do.call(grid.arrange, c(vd.plots, ncol = 4))
dev.off()
When multiple data sets are passed into the function it assumes the second data set is the fontsize when passed to the function itself within ~/modules/uncertainty/plots.R: and overwrites it:
plot.variance.decomposition <- function(plot.inputs, fontsize = list(title = 18, axis = 14)) etc.
Do I have to pass in the inputs into the plot.variance.decomposition differently so that it recognizes it as multiple sensitivity analyses? I don't think this is a syntax update issue. It looks like the 'plot.sensitivities' function is more explicit in how multiple sensitivity analyses are passed in and this works for me.
plot.sensitivities <- function(sensitivity.plot.inputs,
prior.sensitivity.plot.inputs = NULL, ...){
sa.samples <- sensitivity.plot.inputs$sa.samples
sa.splines <- sensitivity.plot.inputs$sa.splines
if(!is.null(prior.sensitivity.plot.inputs)) {
prior.sa.samples <- prior.sensitivity.plot.inputs$sa.samples
prior.sa.splines <- prior.sensitivity.plot.inputs$sa.splines
etc.
.....but still stuck on how to get 'plot.variance.decomposition' to work for multiple data sets.
@braczka yes, this functionality for plot.variance.decomposition
has apparently been lost since v1.1 that supports the code in the results.Rnw
file. You can checkout the file from commit b685f92b409d8e19f649dd52430f63849980cbd7 (perhaps git checkout b685f92 R/plots.R
) or see 70ff in R/plots.R
and follow that template, along with the plot.sensitivities function
when you update plot.variance.decomposition
.
Reassigned to Betsy since she's familiar with ggplot and said she could work on this
The function
plot.trait
and its dependencies were written using the syntax of ggplot2 v 0.90.Mostly this will require changing use of the
opts()
function totheme()
and renamingtheme_xx()
functions toelement_xx()
. There is a comprehensive guide here: https://github.com/wch/ggplot2/wiki/New-theme-systemThis should be very similar to the changes made when I updated the variance decomposition and sensitivity plots (0dde7f07757b82196c83a9b3d0634dd5cf56bebe)
To get a list of the warnings thrown by ggplot2 deprecated functions, try the following: