aesthetics

ggpairs plot with heatmap of correlation values

霸气de小男生 提交于 2019-12-19 07:44:08
问题 My question is twofold; I have a ggpairs plot with the default upper = list(continuous = cor) and I would like to colour the tiles by correlation values (exactly like what ggcorr does). I have this: I would like the correlation values of the plot above to be coloured like this: library(GGally) sample_df <- data.frame(replicate(7,sample(0:5000,100))) colnames(sample_df) <- c("KUM", "MHP", "WEB", "OSH", "JAC", "WSW", "gaugings") ggpairs(sample_df, lower = list(continuous = "smooth")) ggcorr

Shapes and Linetypes in ggplot

此生再无相见时 提交于 2019-12-17 14:52:09
问题 In the following df: > seperate Tenors Ratio Pairs Subgroup 1 1W 93.9426 audusd USD Pairs 2 1M 97.6231 audusd USD Pairs 3 3M 100.0376 audusd USD Pairs 4 6M 108.7951 audusd USD Pairs 5 12M 127.6704 audusd USD Pairs 6 1W 93.6322 eurusd USD Pairs 7 1M 93.5800 eurusd USD Pairs 8 3M 96.2518 eurusd USD Pairs 9 6M 101.1169 eurusd USD Pairs 10 12M 108.7339 eurusd USD Pairs 11 1W 92.8932 gbpusd USD Pairs 12 1M 89.6215 gbpusd USD Pairs 13 3M 83.8495 gbpusd USD Pairs 14 6M 86.3159 gbpusd USD Pairs 15

On aes_string(), factor() and Rstudio's Shiny Package

放肆的年华 提交于 2019-12-12 16:52:24
问题 When I run the following code: graph <- ggplot(data = graphData, aes_string(x = input$variable1, y = input$variable1)) graph <- graph + geom_point( aes_string(colour=input$groupVariable) ) I get the following graph: Which is problematic because it's not grouped by distinct colors, but rather with shades of blue. I want this: I tried to use factor() as in the following: graph <- ggplot(data = graphData, aes_string(x = input$variable1, y = input$variable2)) graph <- graph + geom_point( aes

Modify aes list outside ggplot function

耗尽温柔 提交于 2019-12-12 15:55:57
问题 This is my first question about R in a forum, so sorry in advance if I made any mistake formulating the question or specifying the title. The point is that for a particular task with ggplot I define the aesthetics outside the ggplot function and then provide it as an argument. >mytmpaes<-aes(x=Sample,y=ddCt.lin,ymax=ddCt.lin+ddCt.lin.sd,ymin=ddCt.linddCt.lin.sd,fill=factor(endog)) >my.ggplot(x,mytmpaes) But sometimes I just want to modify some objects of the mytmpaes list without defining all

Colored histogram with ggplot2

孤人 提交于 2019-12-11 03:02:02
问题 I have a data frame with values and their associated weights. I want to make a histogram, such that each bar's height corresponds to the number of values in that bin and the bar's color corresponds to their total weight. How do I do that? Example: D <- data.frame( x = c(-0.39, 0.12, 0.94, 1.67, 1.76, 2.44, 3.72, 4.28, 4.92, 5.53, 0.06, 0.48, 1.01, 1.68, 1.80, 3.25, 4.12, 4.60, 5.28, 6.22), w = c(0.1810479, 0.2209460, 0.2974134, 0.3768152, 0.3871925, 0.4682943, 0.6220371, 0.6838944, 0.7473117,

How to increase the space between grouped bars in ggplot2?

本小妞迷上赌 提交于 2019-12-10 14:23:36
问题 [Data and code to produce plot at the end of the post] Using ggplot, I plotted a bargraph with error bars, bars are grouped by two factors (one on X axis, one with fill). I would like to increase the green distance between the groups on the xaxis to make the plot easier to read: The closest thing to a solution on stackoverflow I found here (where someone asked my question in an unanswered comment), here, here, but I didn't manage to apply these without massing up the error bars. Can someone

How to change default aesthetics in ggplot?

纵饮孤独 提交于 2019-12-08 21:14:52
问题 Let's say that I would prefer geom_point to use circles ( pch=1 ) instead of solid dots ( pch=16 ) by default. You can change the shape of the markers by passing a shape argument to geom_point , e.g. ggplot(diamonds, aes(depth, carat, colour=cut)) + geom_point(shape=1) ggplot(diamonds, aes(depth, carat, colour=cut)) + geom_point(shape=16) but I can't figure out how to change the default behaviour. 回答1: Geom (and stat) default can be updated directly: update_geom_defaults("point", list(shape =

Customizing aesthetics of faceted barplot

柔情痞子 提交于 2019-12-07 06:27:27
问题 I am trying to do some analysis of the recent MLB draft with some ggplots in R selection <- draft[c("Team","Division","Position")] head(selection) Team Division Position 1 pit NL Central P 2 sea AL West P 3 ari NL West P 4 bal AL East P 5 kc AL Central O 6 was NL East I where P = Pitcher , O=Outfield etc. I want to show the number of players selected by team by position within each division p <- ggplot(data=selection, aes(x=Team, fill= Position)) + geom_bar(position="stack") p <- p + coord

Trouble with ggplot in R - “Error in f(…) : Aesthetics can not vary with a ribbon”

岁酱吖の 提交于 2019-12-06 13:40:52
I am trying to plot the plot the data of three constituents on the same plot using ggplot. Specifically, I am trying to get a stacked line/area plot that represents the data distribution. The three constituents each have 451 values, hence why I have put the runif value as 451. The code I am using is: library(dplyr) library(ggplot2) cdom <- t(as.matrix(read.csv("CDOM.csv"))) abcoef <- as.numeric(cdom[2,], cdom[3,], cdom[4,], times=3) wavelength <- as.numeric(cdom[1,], each=3) value <- runif(451, -1, 1) data <- data.frame(abcoef,wavelength,value) ggplot(data, aes(x=wavelength, y=value, fill

Add legend to ggplot histogram with different types of aesthetics

谁都会走 提交于 2019-12-05 19:34:53
I want to add a legend to one of my plots, but I have different aesthetics and I never created a legend so I find it very difficult to determine how to build it. One of my aesthetics is a fill code, which I added manually as a vector. The other aesthetic is a vertical line that I added with geom_vline. From the graph below, there are three characteristics that I want to add to the legend: 1) The bars with color dark blue, 2) The bars with color light blue and 3) The vertical line. Does anyone have a suggestion for me on how to code this efficiently? #df df <- data.frame(Time_Diff <- runif(1000