logo
down
shadow

how to plot a graph on lattice with two different colors


how to plot a graph on lattice with two different colors

By : Thomas Williams
Date : November 22 2020, 10:31 AM
I hope this helps you . I think you want the groups to be the interaction of learner and momentum:
code :
xyplot(rmse ~ epochs, data=data,
       groups = interaction(learner,momentum, sep=" : ", drop=TRUE),
       type = "l",
       auto.key =
           list(space = "right", points = FALSE, lines = TRUE))
xyplot(rmse ~ epochs, data=data,
       groups = paste("L =", learner, "M =", momentum),
       type = "l",
       auto.key =
           list(space = "right", points = FALSE, lines = TRUE))


Share : facebook icon twitter icon
How to plot directed acyclic lattice graph in R

How to plot directed acyclic lattice graph in R


By : Shoaib Khan
Date : March 29 2020, 07:55 AM
it fixes the issue I am not exactly sure what you mean by 'without edges on the contour', but here are some points:
Read ?igraph.plotting for the complete list of plotting parameters. If you don't want the frame on the vertices, set vertex.frame.color to the same value as vertex.color. Use layout.grid, see ?layout.grid. Use vertex.label to set the labels. If you want to omit some edges, then delete them, or set their width to zero or their color to background color. If you want to omit some vertices, then attach the coordinates calculated by layout.grid as vertex attributes, and then remove the vertices from the graph.
code :
g <- graph.lattice( c(5,5) )
lay <- layout.grid(g)
V(g)$x <- lay[,1]
V(g)$y <- lay[,2]
V(g)$color <- V(g)$frame.color <- "darkolivegreen"
V(g)$label.color <- "lightgrey"
V(g)$label <- paste(V(g)$x+1, V(g)$y+1, sep=",")
torem <- c(E(g)[ V(g)[x==0] %--% V(g)[x==0] ], 
           E(g)[ V(g)[y==0] %--% V(g)[y==0] ], 
           E(g)[ V(g)[x==4] %--% V(g)[x==4] ], 
           E(g)[ V(g)[y==4] %--% V(g)[y==4] ])
g2 <- delete.edges(g, torem)
g3 <- delete.vertices(g2, V(g2)[ x %in% c(0,4) & y %in% c(0,4) ])
plot(g3, layout=cbind(V(g3)$x, V(g3)$y))
How to plot a graph in lattice based on columns

How to plot a graph in lattice based on columns


By : user2982381
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Generally lattice functions will be much easier to use with "long data" and yours is unfortunately "wide". The melt function was a great gift to R users (thank you, Hadley).
code :
> dat <- read.table(text="epochs |  lm   |   le  |  kd
+ 1      | 0.38  | 0.25 | 0.21
+ 2      | 0.34  | 0.22 | 0.44
+ 3      | 0.45  | 0.33 | 0.22", header=TRUE,sep="|")
> require(reshape2)
Loading required package: reshape2

> datm <- melt(dat, id.var="epochs")
> str(datm)
'data.frame':   9 obs. of  3 variables:
 $ epochs  : num  1 2 3 1 2 3 1 2 3
 $ variable: Factor w/ 3 levels "lm","le","kd": 1 1 1 2 2 2 3 3 3
 $ value   : num  0.38 0.34 0.45 0.25 0.22 0.33 0.21 0.44 0.22

xyplot(value ~ epochs, groups=variable, datm, type="b",  
         auto.key =  list( space="right", points = FALSE, lines = TRUE) )
Plot different parts of a vector with different colors on the same graph

Plot different parts of a vector with different colors on the same graph


By : Stuffy jackson
Date : March 29 2020, 07:55 AM
Hope that helps Not a base R solution, but I think this is how to plot it using . It is necessary to prepare a data frame to plot the data.
code :
set.seed(1234)

vec <- rnorm(200,5,2)

dat <- data.frame(Value = vec)
dat$Group <- as.character(rep(c(1, 2), each = 100))
dat$Index <- 1:200

library(ggplot2)

ggplot(dat, aes(x = Index, y = Value)) +
  geom_line(aes(color = Group)) +
  scale_color_manual(values = c("blue", "red")) +
  theme_classic()
library(lattice)
xyplot(Value ~ Index, data = dat, type = 'l', groups = Group, col = c("blue", "red"))
dat2 <- dat[dat$Index %in% 101:200, ]

ggplot(dat, aes(x = Index, y = Value)) +
  geom_line(color = "blue") +
  geom_line(data = dat2, aes(x = Index, y = Value), color = "red") +
  theme_classic()
plot.zoo - Plot one graph with different colors

plot.zoo - Plot one graph with different colors


By : vishal patil
Date : March 29 2020, 07:55 AM
I wish this helpful for you If cond is a logical vector with your condition for more volatile periods (for example cond <- abs(Returns > 0.05)), you can use something like:
code :
plot.zoo(djr, xlab = "Time", ylab = "Returns", col = "blue")
points(index(djr)[cond], djr[cond], type = "l", col = "red")
# Reproducible example:
library(zoo)
djr <- as.zoo(EuStockMarkets[, "DAX"])
djr <- (djr - mean(djr))/sd(djr)

cond <- abs(as.numeric(djr)) > 0.75
rlec <- rle(cond)

plot.zoo(djr, xlab = "Time", ylab = "Returns", col = "white")
ind <- 1
for(i in 1:length(rlec$values)) {
  points(index(djr)[ind:(ind + rlec$lengths[i] - 1)], 
         djr[ind:(ind + rlec$lengths[i] - 1)], 
         type = "l", col = c("blue", "red")[rlec$values[i] + 1])
  ind <- ind + rlec$lengths[i]
}
How to plot two list in the same graph, but with different colors?

How to plot two list in the same graph, but with different colors?


By : David Flynn
Date : March 29 2020, 07:55 AM
I wish this helpful for you You should use plt.plot twice to plot two lines.
I don't know what is your X axis but obviously you should create another array/list to be your X value.
Related Posts Related Posts :
  • Conditionally removing rows from a matrix in R
  • Using a loop to find P(-1.5<Y<1.5) for a range of sample sizes
  • R-Count and list the maximum count row by row
  • Include Iverson Bracket in R documentation
  • update a data frame and environment in R
  • How to write dynamic cumulative multiple in R
  • format time using as.POSIX in R
  • Change the class of multiple columns
  • Remove period and spaces within column headings nested in a list of data frames
  • R: error message --- package error: "functionName" not resolved from current namespace
  • labels with geom_text ggplot2
  • Passing mongodb ISODate in R
  • Importing "csv" file with multiple-character separator to R?
  • Change row names of a table obtained from a lm regression using xtable function
  • R language iterate over R object
  • How do you delete the header in a dataframe?
  • Re coding in R using complicated statement
  • accumulating functions and closures in R
  • How do you combine two columns into a new column in a dataframe made of two or more different csv files?
  • Twitter authentication fails
  • Summing Values of One Vector Conditional on Values of Another Vector
  • draw cube into 3D scatterplot in RGL
  • lme4 translate formula to code in 3-level model
  • How to draw single axis plot in R
  • Combine geom_tile() and facet_grid/facet_wrap and remove space between tiles (ggplot2)
  • Use snpStats with R version 3.0.1
  • Makefile gives strange error while compiling markdown file into .docx file
  • How to determine whether a points lies in an ellipse
  • Summarize data already grouped in r
  • Is the bigvis package for R not available for R version 3.0.1?
  • Operator overloading in R reference classes
  • How to enable user to switch between ggplot2 and gVis graphs in R Shiny?
  • Is there an easy way to separate categorical vs continuous variables into two dataset in R
  • Correct previous year by id within R
  • Installation of rdyncall package for R
  • ggplot2 plot that evaluates the percentage and mean of a third variable at intersecting points
  • Error Handling with Lapply
  • data.table - split multiple columns
  • How to compute the overall mean for several files in R?
  • R: Graph Plotting: Subscripts in the legend like LaTeX
  • Restructuring data in R
  • Distance of pointsfrom cluster centers after K means clustering
  • R incorrect value of date function
  • Package "Imports" not loading in R development package
  • r - run a user defined function several times by taking column elements as parameters
  • Create input$selection to subset data AND radiobuttons to choose plot type in Shiny
  • Generate crosstabulations from dataframe of categorical variables in survey
  • Restructure output of R summary function
  • New behavior in data.table? .N / something with `by` (calculate proportion)
  • search certain number vector in R
  • R version doesn't support quartz graphic device - RStudio won't plot
  • Referencing a function parameter in R
  • How to synchronize signals using a cross-correlation and FFT in R?
  • Plotting coefficients and corresponding confidence intervals
  • passing expressions to curve() within a function
  • More effective merging of matched column with duplicates in data.table
  • Easy way to export multiple data.frame to multiple Excel worksheets
  • R Foreach Iterator - Walkforward
  • Table format and output in R
  • Restructuring data and duplicating rows in R
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org