line-plot

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

烂漫一生 提交于 2019-12-02 04:38:27
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? There is a function for this, matplot . Try matplot(yourData, type="l") 来源: https://stackoverflow.com/questions/32254821/r-plot-multiple-columns-as-years-on-x-axis-plot-rows-as-different-lines

Remove seaborn lineplot legend title

对着背影说爱祢 提交于 2019-11-30 06:53:13
I would like to remove the title from my seaborn lineplot legend. I tried using this answer to no avail: import matplotlib.pyplot as plt import seaborn as sns; sns.set() fmri = sns.load_dataset("fmri") fig, ax = plt.subplots() g = sns.lineplot(x="timepoint", y="signal", hue="event", data=fmri, ax=ax) ax.legend().set_title('') I get the same if I try to set the title to None . Interestingly, setting the title to something else seems to prepend to the existing title: ax.legend().set_title('Something else') It almost looks like seaborn is treating the title as a hidden legend entry. How can I

Plotting a horizontal line on multiple subplots in python using pyplot

陌路散爱 提交于 2019-11-28 20:31:30
I am plotting three subplots on the same page. I want to draw a horiZontal line through all the subplots. Following is my code and the resultant graph: (You can notice I can get the horizontal line on one of the plots, but not all) gs1 = gridspec.GridSpec(8, 2) gs1.update(left=0.12, right=.94, wspace=0.12) ax1 = plt.subplot(gs1[0:2, :]) ax2 = plt.subplot(gs1[3:5, :], sharey=ax1) ax3 = plt.subplot(gs1[6:8, :], sharey=ax1) ax1.scatter(theta_cord, density, c = 'r', marker= '1') ax2.scatter(phi_cord, density, c = 'r', marker= '1') ax3.scatter(r_cord, density, c = 'r', marker= '1') ax1.set_xlabel(

Elegant way to select the color for a particular segment of a line plot?

女生的网名这么多〃 提交于 2019-11-27 14:53:14
For a list of n pairs of coordinates x,y is there a way of plotting the line between different points on a specific color? The solution I've implemented so far is not to use the plot function but lines selecting the range for which I want the color. Here an example: x <- 1:100 y <- rnorm(100,1,100) plot(x,y ,type='n') lines(x[1:50],y[1:50], col='red') lines(x[50:60],y[50:60], col='black') lines(x[60:100],y[60:100], col='red') Is there an easier way of doing this? Yes, one way of doing this is to use ggplot . ggplot requires your data to be in data.frame format. In this data.frame I add a

Plotting a horizontal line on multiple subplots in python using pyplot

白昼怎懂夜的黑 提交于 2019-11-27 12:56:57
问题 I am plotting three subplots on the same page. I want to draw a horiZontal line through all the subplots. Following is my code and the resultant graph: (You can notice I can get the horizontal line on one of the plots, but not all) gs1 = gridspec.GridSpec(8, 2) gs1.update(left=0.12, right=.94, wspace=0.12) ax1 = plt.subplot(gs1[0:2, :]) ax2 = plt.subplot(gs1[3:5, :], sharey=ax1) ax3 = plt.subplot(gs1[6:8, :], sharey=ax1) ax1.scatter(theta_cord, density, c = 'r', marker= '1') ax2.scatter(phi

How to change line width in ggplot?

别等时光非礼了梦想. 提交于 2019-11-27 10:26:47
Datalink: the data used My code: ccfsisims <- read.csv(file = "F:/Purdue University/RA_Position/PhD_ResearchandDissert/PhD_Draft/GTAP-CGE/GTAP_NewAggDatabase/NewFiles/GTAP_ConsIndex.csv", header=TRUE, sep=",", na.string="NA", dec=".", strip.white=TRUE) ccfsirsts <- as.data.frame(ccfsisims) ccfsirsts[6:24] <- sapply(ccfsirsts[6:24],as.numeric) ccfsirsts <- droplevels(ccfsirsts) ccfsirsts <- transform(ccfsirsts,sres=factor(sres,levels=unique(sres))) library(ggplot2) #------------------------------------------------------------------------------------------ #### Plot of food security index for

How to plot stacked event duration (Gantt Charts) using Python Pandas?

≯℡__Kan透↙ 提交于 2019-11-27 05:16:16
I have a Pandas DataFrame containing the date that a stream gage started measuring flow and the date that the station was decommissioned. I want to generate a plot showing these dates graphically. Here is a sample of my DataFrame: index StationId amin amax 40623 UTAHDWQ-5932100 1994-07-19 13:15:00 1998-06-30 14:51:00 40637 UTAHDWQ-5932230 2006-03-16 13:55:00 2007-01-24 12:55:00 40666 UTAHDWQ-5932240 1980-10-31 16:00:00 2007-07-31 11:35:00 40697 UTAHDWQ-5932250 1981-06-11 17:45:00 1990-08-01 08:30:00 40728 UTAHDWQ-5932253 2006-06-28 13:15:00 2007-01-24 13:35:00 40735 UTAHDWQ-5932254 2006-06-28

Remove seaborn lineplot legend title

谁说胖子不能爱 提交于 2019-11-27 01:56:23
问题 I would like to remove the title from my seaborn lineplot legend. I tried using this answer to no avail: import matplotlib.pyplot as plt import seaborn as sns; sns.set() fmri = sns.load_dataset("fmri") fig, ax = plt.subplots() g = sns.lineplot(x="timepoint", y="signal", hue="event", data=fmri, ax=ax) ax.legend().set_title('') I get the same if I try to set the title to None . Interestingly, setting the title to something else seems to prepend to the existing title: ax.legend().set_title(

Elegant way to select the color for a particular segment of a line plot?

偶尔善良 提交于 2019-11-26 16:56:55
问题 For a list of n pairs of coordinates x,y is there a way of plotting the line between different points on a specific color? The solution I've implemented so far is not to use the plot function but lines selecting the range for which I want the color. Here an example: x <- 1:100 y <- rnorm(100,1,100) plot(x,y ,type='n') lines(x[1:50],y[1:50], col='red') lines(x[50:60],y[50:60], col='black') lines(x[60:100],y[60:100], col='red') Is there an easier way of doing this? 回答1: Yes, one way of doing

How to change line width in ggplot?

此生再无相见时 提交于 2019-11-26 15:09:02
问题 Datalink: the data used My code: ccfsisims <- read.csv(file = "F:/Purdue University/RA_Position/PhD_ResearchandDissert/PhD_Draft/GTAP-CGE/GTAP_NewAggDatabase/NewFiles/GTAP_ConsIndex.csv", header=TRUE, sep=",", na.string="NA", dec=".", strip.white=TRUE) ccfsirsts <- as.data.frame(ccfsisims) ccfsirsts[6:24] <- sapply(ccfsirsts[6:24],as.numeric) ccfsirsts <- droplevels(ccfsirsts) ccfsirsts <- transform(ccfsirsts,sres=factor(sres,levels=unique(sres))) library(ggplot2) #---------------------------