I'm using the function waterfall from GenVisR package. As the vignette suggests, I am changing the top plot with custom values. However, those values cannot be specified and appear in gray as "Undefined" (see image)
.
I would like to add a layer with ggplot in order to define (and colour) the barplot like the following plot:
In the vignette the authors have an argument called mutBurdenLayer that seems to do the job but I'm not able to change the graph.
Any ideas?
Here is my code:
library(GenVisR)
library(ggplot2)
library(RColorBrewer)
custom_pallete <- brewer.pal(8, "Paired")
waterfall(VCFs, coverageSpace = 179977, main_geneLabSize = 5,
mainLabelSize = 2, mainLabelCol="HGVSp", mainDropMut = T,
mainPalette = custom_pallete, mainXlabel = T)
I would like to add something like:
mut_burden_layer <- theme(...)
waterfall(VCFs, coverageSpace = 179977, main_geneLabSize = 5,
mainLabelSize = 2, mainLabelCol="HGVSp", mainDropMut = T,
mainPalette = custom_pallete, mutBurden = mut, mainXlabel = T,
mutBurdenLayer = mut_burden_layer)
Being mutBurden a data table with the new proportions and mutBurdenLayer the parameter I would like to custom.
Related
I am trying to plot a likert scale of a 1 - 7 scale for every country with the likert package in R, but the R base plot() function won't change any of the text sizes (or even add a main title).
I am generating the plot with:
p <- likert(summary = data )
plot(p,
plot.percents=FALSE,
plot.percent.low=FALSE,
plot.percent.high=FALSE,
include.center=TRUE,
plot.percent.neutral = FALSE,
col = c(brewer.pal(n = 7, name = "RdBu")),
cex.axis = 0.5,
cex.lab=0.5,
main = "title")
Which produces the following plot:
Plot of Countries of the World
All the other plot parameters are working, so I'm not sure why the last 3, the most basic aren't working.
I fixed this by using theme(axis.text) like so:
plot(p,
plot.percents=FALSE,
plot.percent.low=FALSE,
plot.percent.high=FALSE,
include.center=TRUE,
plot.percent.neutral = FALSE,
col = c(brewer.pal(n = 7, name = "RdBu")),
main = "title") +
theme(axis.text=element_text(size=4)
This doesn't answer the larger question as to why the plot() function isn't accepting the parameters, as the title still isn't showing, but it's a band aid solution
I'm trying to make a highcharter item type plot, but I can't make the groups nor the facets like I need. I've been following the existing examples given here and in the highcart's API documentation, but I haven't been able to adapt them to what I need.
The plot data is here. Using said data; this is what I got using ggplot2 + plotly in the meantime. Can you help me replicate this using highcharter?
library(ggplot2)
library(plotly)
ggplotly(ggplot(plot_data, aes(x, y, size = 3, color = Partido, text = name, label = Partido)) +
geom_point() +
facet_wrap(~`¿Cómo votó?`)
)
Output:
Using list() already converts to an items object, like example from this post.
data = list(
list(from = 'Brazil', to = 'Portugal'),
list(from = 'Brazil', to = 'Spain'),
list(from = 'Poland', to = 'England'))
Probably module modules/item-series.js not exist on Highcharter, you can report request for adding on https://github.com/jbkunst/highcharter/issues.
I have made a RGB composite image of a satellite image using ggRGB() from the RStoolbox package. I would like to add a scale bar to the image, but I'm stumped as to how to do this. I would usually use scalebar() from the ggsn package when working with ggmaps() in R, but it doesn't look like it can handle a RasterBrick object as input like like is required for ggRGB().
Here is an example:
library(raster)
library(ggplot2)
library(RStoolbox)
data(lsat)
ggRGB(img = lsat,
r = 3,
g = 2,
b = 1,
stretch = 'hist') +
blank() # eliminate x and y axes
This produces the following image:
I would like to add a scale bar in the upper right corner. Here's what I tried:
ggRGB(img = lsat,
r = 3,
g = 2,
b = 1,
stretch = 'hist') +
blank() +
ggsn::scalebar(lsat, dist = 2, dist_unit = "km",
transform = TRUE, model = "WGS84", location = "upperright")
This returns an error: "Error in .local(x, ...) : invalid layer names"
Any help would be much appreciated. I'd like to stick with ggRGB() if possible, but I'd be open to other plotting methods if I can place a scale bar on the image.
You could use package ggspatial
ggRGB(img = lsat,
r = 3,
g = 2,
b = 1,
stretch = 'hist') +
theme_void() +
ggspatial::annotation_scale(location = "tr", width_hint =0.5, pad_x = unit(0.7, "cm"))
If you want more fine control over the appearance, a slightly more verbose but highly customizable method is also given in this answer https://stackoverflow.com/a/39069955/2761575
I am currently following a tutorial to graph some data using qichart2. When I input the code, it creates a List instead of a graph. The same thing happened to me previously when I was trying to follow a plotly tutorial.
ControlChart <- qic(Force,
data = HudsonData,
chart = 'i',
title = NULL,
xlab = NULL,
x = TimeStamp,
ncol = 1,
show.labels = TRUE,
point.size = 3,
scales = "free_y",
facets = ~ Limb)
This creates a List of 9 instead of a plot like it did in the tutorial.
Is there something I have set up in my R Studio that is creating Lists instead of plots? When I use ggplot2 plots work fine.
Let me know if more info is needed that would be helpful.
I'm looking for a way to duplicate the kind of Heat Table shown below with R (and possibly ggplot2). Specific time axis are irrelevant; any rectangular table should do.
I've tried to search for Heat map and Heat table in Google, but couldn't find any R package that did the trick.
Thoughts?
require(ggplot2)
df <- data.frame(vaxis = rep(c(letters[1:5], "top"), each = 4),
haxis = rep(c(letters[6:8], "right"), times = 6),
value = rpois(24, lambda = 10))
df$color <- factor(ifelse(df$vaxis == "top" | df$haxis == "right", 1, 0))
ggplot(df, aes(x = haxis, y = vaxis, size = value, color = color)) + geom_point()
Just get your data in a similar format. You could write a function to make the "top" and "right" values normalized marginal sums. Of course lots of tweaks are possible in naming, legends, theme, etc.