plot

Plot conditional color with NA data

蹲街弑〆低调 提交于 2021-02-11 12:21:59
问题 I have a data frame in R that has 2 numeric fields, 1 of these fields can contain NA values. I want to plot the first field and base the col off if the second field is NA or not. CurrentBackLog = as.data.frame(list(DaysSinceCreted=c(34,50,22,6),DaysSinceReady=c(NA,10,22,NA))) This only shows the items where DaysSinceReady is NOT NA... plot(CurrentBackLog$DaysSinceCreated, main = 'Days Since Created by Ticket', ylab = 'Days Since Created', pch = 15, col = ifelse(CurrentBackLog$DaysSinceReady>1

R-Project: How to limit axes in SPI plot? ylim & xlim don't work

二次信任 提交于 2021-02-11 08:59:28
问题 Dear stackoverflow community, I'm quite new in R and this is my first stackoverflow entry so please show mercy with me if it's not the perfect questioning. I'm calculating standardized precipitation index (SPI) with the package "SPEI" for a time series of a climate station with 20 years of monthly precipitation data. I have done this for the timescale of 1 and 12 month like this: spi1 <- spi(SPI_Anu_input_ts[,'PRCP_Anu'], 1) spi12 <- spi(SPI_Anu_input_ts[,'PRCP_Anu'], 12) The output of SPI is

Different color for different cluster in a tree using adegenet R package

我的未来我决定 提交于 2021-02-11 08:35:10
问题 I am using the R package adegenet to plot the neighbor-joining tree. In my file I have 20,000 columns and 500 rows. Rows correspond to individuals. My first column is Population ID and second column is Individual ID. Columns contain values 0,1 & 2. I am able to plot a tree in one color, but depending upon the population I want every cluster to be a different color. This is what I did, If "dat" is my data file,then D<-dist(as.matrix(dat)) tre<-nj(D) plot(tre, type = "unr", show.tip.lab = TRUE,

How to highlight a plotline chart with vertical color bar for specific weekdays (saturday and sunday)? [duplicate]

冷暖自知 提交于 2021-02-11 06:52:11
问题 This question already has answers here : how to highlight weekends for time series line plot in python (2 answers) Closed 3 days ago . i plotted a daily line plot for flights and i would like to highlight all the saturdays and sundays. I'm trying to do it with axvspan but i'm struggling with the use of it? Any suggestions on how can this be coded? (flights.loc[flights['date'].dt.month.between(1, 2), 'date'] .dt.to_period('D') .value_counts() .sort_index() .plot(kind="line",figsize=(12,6)) )

R: How to Draw heat map divided by a digonal line?

时光总嘲笑我的痴心妄想 提交于 2021-02-10 23:51:02
问题 I came across this article on Nature Methods which provided a very nice heatmap: http://www.nature.com/nmeth/journal/v12/n4/full/nmeth.3311.html Different from other heat map is each rectangle is divided by a diagonal line, with 1 part represent the literature data and the other in-house data. I think this is a very nice way to compare the data. However, I do not know how to draw this pic in R. Does anyone have any clue on how to do this? A small screenshot is provided below: Below is a demo

R: How to Draw heat map divided by a digonal line?

元气小坏坏 提交于 2021-02-10 23:43:37
问题 I came across this article on Nature Methods which provided a very nice heatmap: http://www.nature.com/nmeth/journal/v12/n4/full/nmeth.3311.html Different from other heat map is each rectangle is divided by a diagonal line, with 1 part represent the literature data and the other in-house data. I think this is a very nice way to compare the data. However, I do not know how to draw this pic in R. Does anyone have any clue on how to do this? A small screenshot is provided below: Below is a demo

Error: Too few points to calculate an ellipse with 3 points? - R

梦想与她 提交于 2021-02-10 18:36:12
问题 G'day. I am plotting a pca with the factoextra package. I have 3 points for each factor and would like to draw ellipses around each. But I am getting the error Too few points to calculate an ellipse . It is possible to draw ellipses around 3 points in ggplot2 with the stat_ellipse function. I can confirm this by looking at the calculate_ellipse code from ggplot2 that says else if (dfd < 3) {message("Too few points to calculate an ellipse") . So what ellipse function is factoextra using in

Is there a way to create a 3d plot with contours beneath the plot in R?

白昼怎懂夜的黑 提交于 2021-02-10 18:33:11
问题 Is there a way to create a 3d plot in R that has contours beneath the plot like so? If not, is there a way to take my existing contour plot and put it on top of the 3d persp plot? I have been able to make a 3d plot, and a contour plot of the function and constraint, but have not been able to combine the two. Here is my R code: obj = function(x1,x2){ value = -(cos((x1-.1)*x2))^2 - x1*sin(3*x1+x2) return(value) } con1 = function(x1,x2){ t = atan2(x1,x2) value = x1^2 + x2^2 -((2*cos(t)-1/2*cos(2

R - how to filter data with a list of arguments to produce multiple data frames and graphs

自闭症网瘾萝莉.ら 提交于 2021-02-10 18:30:43
问题 I am looking for a way to use a list of filter arguments to produce different objects. I have a data set for which I want to make several graphs. However, I want all these graphs based on subsets of the dataset. For illustrative purposes I have made the following data. df <- data.frame(type = c("b1", "b2", "b1", "b2"), yield = c("15", "10", "5", "0"), temperature = c("2", "21", "26", "13"), Season = c("Winter", "Summer", "Summer", "Autumn"), profit = c(TRUE, TRUE, FALSE, FALSE)) Also, I have

Is there a Python package that can trace a curve with a Gaussian lineshape over several x and y values?

人盡茶涼 提交于 2021-02-10 18:29:21
问题 My apologies for my ignorance in advance; I've only been learning Python for about two months. Every example question that I've seen on Stack Overflow seems to discuss a single distribution over a series of data, but not one distribution per data point with band broadening. I have some (essentially) infinitely-thin bars at value x with height y that I need to run a line over so that it looks like the following photo: The bars are the obtained from the the table of data on the far right. The