line-plot

JFreeChart: How to plot a line graph and a scatter on same chart

谁说胖子不能爱 提交于 2019-12-07 17:47:35
问题 i have two sets of data int[] x1 = {1,2,3,4,5,6,7,8,9,10}; int[] y1 = {1,2,3,5,6,8,9,10,14,11}; int[] x2 = {1,2,3,4,5,6,7,8,9,10}; int[] y2 = {0,2,3,5,0,8,9,8,14,11}; int[] z2 = {1,2,3,1,2,3,1,2,3,1}; I want to plot the x1,y1 as an XYLineChart and then plot x2,y2 as a scatter on the same plot without a line. I also need each scatter point of xy,y2 to be a different color depending on the value of z2 (1=Color.red, 2=Color.green, 3=Color.blue) How can i do this? So far i have: JPanel panel_1 =

Custom ggplot2 shaded error areas on categorical line plot

筅森魡賤 提交于 2019-12-06 13:40:08
问题 I'm trying to plot a line, smoothed by loess, but I'm trying to figure out how to include shaded error areas defined by existing variables, but also smoothed. This code creates example data: set.seed(12345) data <- cbind(rep("A", 100), rnorm(100, 0, 1)) data <- rbind(data, cbind(rep("B", 100), rnorm(100, 5, 1))) data <- rbind(data, cbind(rep("C", 100), rnorm(100, 10, 1))) data <- rbind(data, cbind(rep("D", 100), rnorm(100, 15, 1))) data <- cbind(rep(1:100, 4), data) data <- data.frame(data)

JFreeChart: How to plot a line graph and a scatter on same chart

我只是一个虾纸丫 提交于 2019-12-06 02:59:18
i have two sets of data int[] x1 = {1,2,3,4,5,6,7,8,9,10}; int[] y1 = {1,2,3,5,6,8,9,10,14,11}; int[] x2 = {1,2,3,4,5,6,7,8,9,10}; int[] y2 = {0,2,3,5,0,8,9,8,14,11}; int[] z2 = {1,2,3,1,2,3,1,2,3,1}; I want to plot the x1,y1 as an XYLineChart and then plot x2,y2 as a scatter on the same plot without a line. I also need each scatter point of xy,y2 to be a different color depending on the value of z2 (1=Color.red, 2=Color.green, 3=Color.blue) How can i do this? So far i have: JPanel panel_1 = new JPanel(); panel_1.setLayout(new BorderLayout(0, 0)); XYSeriesCollection dataset = new

Line plot of multiple variables in R

感情迁移 提交于 2019-12-04 23:50:34
问题 I have input data in below format. x y z 0 2.2 4.5 5 3.8 6.8 10 4.6 9.3 15 7.6 10.5 How can i plot the xy scatter plot like excel (show below) in R? 回答1: There at least four ways of doing this: 1) Use a "horizontal" or "wide" data.frame called df here df <- data.frame(x = c(0, 5, 10, 15), y = c(2.2, 3.8, 4.6, 7.6), z = c(4.5, 6.8, 9.3, 10.5)) ggplot(df, aes(x)) + geom_line(aes(y = y, colour = "y")) + geom_line(aes(y = z, colour = "z")) 2) Using lattice require(lattice) xyplot(x ~ y + z, data

Custom ggplot2 shaded error areas on categorical line plot

試著忘記壹切 提交于 2019-12-04 19:31:16
I'm trying to plot a line, smoothed by loess, but I'm trying to figure out how to include shaded error areas defined by existing variables, but also smoothed. This code creates example data: set.seed(12345) data <- cbind(rep("A", 100), rnorm(100, 0, 1)) data <- rbind(data, cbind(rep("B", 100), rnorm(100, 5, 1))) data <- rbind(data, cbind(rep("C", 100), rnorm(100, 10, 1))) data <- rbind(data, cbind(rep("D", 100), rnorm(100, 15, 1))) data <- cbind(rep(1:100, 4), data) data <- data.frame(data) names(data) <- c("num", "category", "value") data$num <- as.numeric(data$num) data$value <- as.numeric

Line plot of multiple variables in R

放肆的年华 提交于 2019-12-03 15:22:13
I have input data in below format. x y z 0 2.2 4.5 5 3.8 6.8 10 4.6 9.3 15 7.6 10.5 How can i plot the xy scatter plot like excel (show below) in R? There at least four ways of doing this: 1) Use a "horizontal" or "wide" data.frame called df here df <- data.frame(x = c(0, 5, 10, 15), y = c(2.2, 3.8, 4.6, 7.6), z = c(4.5, 6.8, 9.3, 10.5)) ggplot(df, aes(x)) + geom_line(aes(y = y, colour = "y")) + geom_line(aes(y = z, colour = "z")) 2) Using lattice require(lattice) xyplot(x ~ y + z, data=df, type = c('l','l'), col = c("blue", "red"), auto.key=T) 3) Turn your original df into a "long" data.frame

Making line plot with discrete x-axis in ggplot2

淺唱寂寞╮ 提交于 2019-12-02 18:03:32
问题 I am building a ggplot2 figure with a facet grid. On my Y-axis are percentages, and my X-axis is the concentration (in numbers). Each facet has 3 groups (0, 24 and 48 hours) ggplot(data=MasterTable, aes(x=Concentration, y=Percentage, group=Time)) + geom_point() + geom_line() + facet_grid(Chemicals ~ Treatments) This generates a continuous x-axis. Since the values are not evenly spread out, I would prefer a discrete axis to better visualize my data. I followed the following tutorial with no

Making line plot with discrete x-axis in ggplot2

匆匆过客 提交于 2019-12-02 10:30:20
I am building a ggplot2 figure with a facet grid. On my Y-axis are percentages, and my X-axis is the concentration (in numbers). Each facet has 3 groups (0, 24 and 48 hours) ggplot(data=MasterTable, aes(x=Concentration, y=Percentage, group=Time)) + geom_point() + geom_line() + facet_grid(Chemicals ~ Treatments) This generates a continuous x-axis. Since the values are not evenly spread out, I would prefer a discrete axis to better visualize my data. I followed the following tutorial with no luck. The first figure is exactly what I am trying to do. I also tried formatting the axis: scale_x

Change size of a line plot, understand how the size argument works

孤人 提交于 2019-12-02 08:07:55
I'm making a multiple lines plot with errorbars. If I don't use the size argument, everything is fine: # sample data Response=runif(4) ResponseMin=Response-Response/5 ResponseMax=Response+Response/5 Cases=rep(c("Case1","Case2"),each=2) df=data.frame(x=1:2,Average=Response,Lower=ResponseMin,Upper=ResponseMax,Case=Cases) # let's plot library(ggplot2) ggplot(df,aes(x=x,y=Average,colour=Case)) + geom_line(aes(group=Case)) + geom_point() + geom_errorbar(aes(ymin=Lower,ymax=Upper,width=0.25)) + labs(y="foo",title="Some plot fu") However, when I modify the line size, I start getting weird stuff:

R - Plot multiple columns as years on x-axis, plot rows as different lines

天涯浪子 提交于 2019-12-02 06:48:42
问题 Here's my data frame: 2010 2011 2012 2013 2014 2015 A 0 100 164 75 154 110 B 71 77 136 58 138 136 C 0 0 132 53 83 0 I'd like to make a line graph in which the years are plotted along the x-axis and and counts are plotted along the y-axis, with rows A, B, and C each having their own line. Is it possible to do this without melting the years into a single variable? 回答1: There is a function for this, matplot . Try matplot(yourData, type="l") 来源: https://stackoverflow.com/questions/32254821/r-plot