similar to: Getting discrete colors on plot

Displaying 20 results from an estimated 4000 matches similar to: "Getting discrete colors on plot"

2012 Feb 04
1
GGPLOT2: Distance of discrete values of from each end of x-axis
Hi Group, I have been working with the code below. Everything seems to work okay, except that the discrete values on the x-axis are far from each end of the graph. I've tried several things including changing the discrete values and playing with the limits, but can't get it to work. I tested this on simulated data and do not have the same problem, so I guessing it is how I'm
2013 Apr 14
1
Problem plotting continuous and discrete series in ggplot with facet
I have data that plots over time with four different variables. I would like to combine them in one plot using facet_grid, where each variable gets its own sub-plot. The following code resembles my data require(ggplot2) require(reshape2) subm <- melt(economics, id='date', c('psavert','uempmed','unemploy')) mcsm <- melt(data.frame(date=economics$date,
2012 Jan 16
1
ggplot- using geom_point and geom_line at the same time
Hi I am plotting line chart using ggplot and want to use geom_line and geom_point simultaneously. I get the plot but now I have two legends. None of the legend is representing the true values. I need the legend with shape and color both. Thanks > con = textConnection("inputs var1 var2 var3+ 100 10 5 2+ 1000 20 10 4+ 5000 30 15 8+ 10000 40 20 16+ 30000 50 25 32")> data =
2013 Feb 01
2
Change default order of colors & line types
Dear R users, I'd like to change the default order of colors & line types. Especially I am using ggplot2 and using color Set1. In Set1, the default color order is red, blue, green, violet,.. ect. However, I want to put red in fourth (not first). Likewise, I want to change the order of default linetype. I want to put "solid" line in fourth. How can I do thses? R code to draw the
2017 Oct 12
2
dual y-axis for ggplot
Hi, To my knowledge, an excellent of ggplot with a second y-axis is https://rpubs.com/MarkusLoew/226759 In this example, the author uses two colors for the two lines, but the line shapes are the same -- both are solid. Could each line have its own color as well as its own shape? For example, can I make the red line with the linetype "twodash", while the blue line with the
2012 Feb 16
2
Problem building up ggplot graph in a loop.
Folks, I want to automate some graphing using ggplot. Here is my code graphChargeOffs2<-function(coffs) { ggplot(coffs, aes(levels)) dataNames<-names(coffs)[!names(coffs) == "levels"] for(i in dataNames) { thisData<-coffs[[i]] last_plot() + geom_line(aes(y = thisData, colour = i)) } last_plot() + ylab("Total Chargeoffs") } coffs is a data.frame.
2011 Jul 24
1
barplot colors
Hi, In barplot(height, col = ...), the col = vector recycles so that the same colors are used for each bar. I would like to use different colors in different bars (corresponding to another piece of information, here, the region of the country being represented). For example, x = matrix(c(5,2,3,1),nrow=2) barplot(x,col=1:4) will draw two bars with two segments each, but each colored red and
2013 Jun 11
0
a title on the map (function gvisGeoChart package googleVis )
Hi I am using the package googleVis and the function gvisGeoChart Is it possible to put a title on the map ? Here is the call of the function : library(googleVis) G1 <- gvisGeoChart(PaysProjets, locationvar=''Pays'', colorvar=''NbProj'', options=list( region= "world", displayMode="regions", height=347*1.5, width= 556*1.5 )) plot(G1) Thank
2017 Oct 12
0
dual y-axis for ggplot
Sorry let me clarify. If I modify the line p <- p + geom_line(aes(y = air_temp, colour = "Temperature")) by p <- p + geom_line(aes(y = air_temp, colour = "Temperature", linetype ="Temperature")) and p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity")) by p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity",
2017 Oct 12
1
dual y-axis for ggplot
Hi John, You can try the following: override.linetype=c("twodash","solid") p <- ggplot(obs, aes(x = Timestamp)) p <- p + geom_line(aes(y = air_temp, colour = "Temperature", linetype ="Temperature")) p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity", linetype="Humidity")) p <- p +
2010 May 10
1
ggplot: Trouble with xlim() and discrete scales
I'm learning ggplot and am a little confused. Sometimes discrete scales work like I'd expect, and sometimes they don't. For example... This works exactly like one would expect: df<-data.frame(names=c("Bob","Mary","Joe","Bob","Bob")) ggplot(df,aes(names))+geom_histogram() But this yields an error:
2018 Jul 18
2
Legendas en una gráfica de ggplot2
Buenas tardes, estoy haciendo una gráfica de múltiples lineas pero no he podido generar las legendas. Alguno de ustedes me podría colaborar. library(ggplot2) #### Con b=-2 t=seq (-4, 4, by=0.01) l=exp(t+2)/(1+(exp(t+2))) ##con b igual a -1 t=seq (-4, 4, by=0.01) o=exp(t+1)/(1+(exp(t+1))) ### Con b igual a 0.7 t=seq (-4, 4, by=0.01) i=exp(t-0.7)/(1+(exp(t-0.7))) ### Con b igual a 2 t=seq
2008 Mar 29
1
Tabulating Sparse Contingency Table
I have a sparse contingency table (most cells are 0): > xtabs(~.,data[,idx:(idx+4)]) , , x3 = 1, x4 = 1, x5 = 1 x2 x1 1 2 3 1 0 0 31 2 0 0 112 3 0 0 94 , , x3 = 2, x4 = 1, x5 = 1 x2 x1 1 2 3 1 0 0 0 2 0 0 0 3 0 0 0 , , x3 = 3, x4 = 1, x5 = 1 x2 x1 1 2 3 1 0 0 0 2 0 0 0 3 0 0 0 , , x3 = 1, x4
2010 Nov 04
5
ggplot output
Dear All, I have this script: dat <- data.frame(Month = hstat$Date,C_avg = hstat$C.avg,C_stdev = hstat$C.stdev) ggplot(data = dat, aes(x = Month, y = C_avg, ymin = C_avg - C_stdev, ymax = C_avg + C_stdev)) + geom_point() + geom_line() + geom_errorbar() dat <- data.frame(Month = hstat$Date,K_avg = hstat$K.avg,K_stdev = hstat$K.stdev) ggplot(data = dat, aes(x = Month, y = K_avg,
2017 Oct 13
4
[FORGED] can't print ggplot with Chinese characters to pdf files
Hi By the looks of it, you need to install Cairo graphics ... https://www.cairographics.org/download/ Paul On 13/10/17 15:48, John wrote: > Thanks, Paul. Following your solution, ?I got this error message: > > Warning message: > In cairo_pdf("test_plot_chinese.pdf") : failed to load cairo DLL > > Is there anything else I need to install? > > Thanks, >
2011 Apr 08
3
xyplot, groups and colors
Dear ExpeRts, I am trying to plot a bunch of growth curves and would like to get some more control over groups and line colors than I seem to have. Example: # make some data dat <- Orange dat$group <- ifelse(dat$Tree%in%c('1','4','5'), 'A', 'B') # plot xyplot(circumference~age, dat, groups=group) # now use lines to make the growth curve more
2018 May 22
3
legend order in ggplot2
Hi, I'd like to graph three lines on ggplot2 and I intend the lines to be "solid", "dashed", and "dotted". The legend names are "name_b", "name_a", "name_c". I'd like to legend to present in the order: the "name_b" at the top, and "name_c" at the bottom. As a consequence, the legend is indeed in the order:
2020 Sep 10
5
aplicar codigo
Hola: Como dice Carlos, algo así, por ejemplo: transforma <- function(df) sapply(df, function(x) ifelse(x%in%c("x1","x2","x3"), "prueba1",ifelse(x%in%c("x4","x5","x6"),"prueba2",x))) > transforma(df1)       col1  [1,] "prueba1"  [2,] "prueba1"  [3,] "x11"  [4,]
2011 Oct 31
3
How to get Quartiles when data contains both numeric variables and factors
When data contains both factor and numeric variables, how to get quartiles for all numeric variables? n <- 100 x1 <- runif(n) x2 <- runif(n) x3 <- x1 + x2 + runif(n)/10 x4 <- x1 + x2 + x3 + runif(n)/10 x5 <- factor(sample(c('a','b','c'),n,replace=TRUE)) x6 <- factor(1*(x5=='a' | x5=='c')) data1 <- cbind(x1,x2,x3,x4,x5,x6) data
2017 Oct 13
1
[FORGED] can't print ggplot with Chinese characters to pdf files
Hi Instead of ... ggsave("test_plot_chinese.pdf", m2) ... try ... cairo_pdf("test_plot_chinese.pdf") print(m2) dev.off() Paul On 13/10/17 02:12, John wrote: > I install the Chinese font "Kaiti TC" on my mac, but I can't print the > figures to pdf file by "marrangeGrob" command, which is in the package > "gridExtra". Error message