ggplot2

ggplot2 theme: axis.text not inheriting from text?

杀马特。学长 韩版系。学妹 提交于 2021-02-10 07:29:27
问题 The current documentation for theme element axis.text says: axis.text tick labels along axes (element_text; inherits from text) but it seems like the inheritance isn't working. This code gives the plot below, with axis text in grey. library(ggplot2) ggplot(data.frame(x=1:10, y=1:10), aes(x, y)) + geom_point(color='red') + theme(rect = element_rect(fill = 'black'), line = element_line(color = 'white'), text = element_text(color = 'blue'), panel.background = element_blank()) Setting axis.text

Repel geom label and text in ggplot. And ordering geom points based on size

江枫思渺然 提交于 2021-02-10 06:35:09
问题 I have 2 data frames such as these: df1 <- data.frame( party = c("Blue Party", "Red Party"), dim1 = c(0.03, -0.04), dim2 = c(-0.05, 0.02), sz = c(34, 42) ) df2 <- data.frame( var = c("Economic", "Gov trust", "Inst trust", "Nationalism", "Religiosity"), dim1 = c(0.1, -0.5, 0, 0.6, 0.4), dim2 = c(0.1, 0.6, 0, 0, 0.3) ) I want to plot the parties from df1 as points defined by size and include arrows based on df2 on the same graph. I've used ggplot to do this: ggplot(df1, aes(x = dim1, y = dim2,

How to make variable width histogram in R with labels aligned to bin edges?

眉间皱痕 提交于 2021-02-10 06:13:20
问题 I'm using ggplot2 , which by default creates histograms with fixed bin widths and whose bin labels are plotted in the center of each bin. What I want instead is a variable-width histogram whose bin labels are representative of the end points of each bin, like this plot: To produce this example plot, I manually entered the bin parameters and shifted the bins to align them with their end points: income=data.frame(lx=c(0,10,25,50,100),rx=c(10,25,50,100,150),y=c(20,28,27,18,7)) income$width =

Errorbars on grouped barplots in ggplot2

会有一股神秘感。 提交于 2021-02-10 06:12:56
问题 I need to plot a grouped barplot with different error bars for each bar in each group. I have managed to plot the chart and add the error bars but they are not positioned correctly on the graph (see below) I know I know I need to somehow tell the errorbars which Genotype they need to be attached to, but I'm not quite sure how. I have tried to use this: Grouped barplot in R with error bars but can't work out what's different. Code: ggplot(data=leaf_level) + geom_bar(aes(x=factor(DAS), y=Total

How to make variable width histogram in R with labels aligned to bin edges?

前提是你 提交于 2021-02-10 06:11:44
问题 I'm using ggplot2 , which by default creates histograms with fixed bin widths and whose bin labels are plotted in the center of each bin. What I want instead is a variable-width histogram whose bin labels are representative of the end points of each bin, like this plot: To produce this example plot, I manually entered the bin parameters and shifted the bins to align them with their end points: income=data.frame(lx=c(0,10,25,50,100),rx=c(10,25,50,100,150),y=c(20,28,27,18,7)) income$width =

How to make variable width histogram in R with labels aligned to bin edges?

我是研究僧i 提交于 2021-02-10 06:10:42
问题 I'm using ggplot2 , which by default creates histograms with fixed bin widths and whose bin labels are plotted in the center of each bin. What I want instead is a variable-width histogram whose bin labels are representative of the end points of each bin, like this plot: To produce this example plot, I manually entered the bin parameters and shifted the bins to align them with their end points: income=data.frame(lx=c(0,10,25,50,100),rx=c(10,25,50,100,150),y=c(20,28,27,18,7)) income$width =

How to make variable width histogram in R with labels aligned to bin edges?

人盡茶涼 提交于 2021-02-10 06:10:20
问题 I'm using ggplot2 , which by default creates histograms with fixed bin widths and whose bin labels are plotted in the center of each bin. What I want instead is a variable-width histogram whose bin labels are representative of the end points of each bin, like this plot: To produce this example plot, I manually entered the bin parameters and shifted the bins to align them with their end points: income=data.frame(lx=c(0,10,25,50,100),rx=c(10,25,50,100,150),y=c(20,28,27,18,7)) income$width =

How to make variable width histogram in R with labels aligned to bin edges?

£可爱£侵袭症+ 提交于 2021-02-10 06:09:26
问题 I'm using ggplot2 , which by default creates histograms with fixed bin widths and whose bin labels are plotted in the center of each bin. What I want instead is a variable-width histogram whose bin labels are representative of the end points of each bin, like this plot: To produce this example plot, I manually entered the bin parameters and shifted the bins to align them with their end points: income=data.frame(lx=c(0,10,25,50,100),rx=c(10,25,50,100,150),y=c(20,28,27,18,7)) income$width =

how can I eliminate placeholder white space from shiny apps?

佐手、 提交于 2021-02-10 05:42:58
问题 When making shiny apps I often struggle with how to arrange plots and text outputs on the page for the user. So, I like to try an make it possible for a user to select which output to display. For instance, the user may be able to display 3 graphs and 2 chunks of text but may only want to display the first graph and one chunk of text. I can usually accomplish this using if statements inside of render functions. But, I have found shiny will still add white space even if...the user does not

Passing extra arguments to ggplot2 geoms: using ellipsis (…)

怎甘沉沦 提交于 2021-02-10 05:40:33
问题 This is a follow-up on this question. I am trying to write my own geoms with custom parameters. My question is how to use ellipsis (...) to pass extra arguments. The following example code works as expected: draw_panel_func <- function(data, panel_params, coord, showpoints=FALSE) { print(showpoints) if(showpoints) { coords <- coord$transform(data, panel_params) grid::pointsGrob(coords$x, coords$y) } else { zeroGrob() } } ## definition of the new geom. setup_data inserts the parameter ## into