Quantcast
Channel: Plot two graphs in a same plot - Stack Overflow
Viewing all articles
Browse latest Browse all 18

Answer by Alessandro Jacopson for Plot two graphs in a same plot

$
0
0

Idiomatic Matlab plot(x1,y1,x2,y2) can be translated in R with ggplot2 for example in this way:

x1 <- seq(1,10,.2)df1 <- data.frame(x=x1,y=log(x1),type="Log")x2 <- seq(1,10)df2 <- data.frame(x=x2,y=cumsum(1/x2),type="Harmonic")df <- rbind(df1,df2)library(ggplot2)ggplot(df)+geom_line(aes(x,y,colour=type))

enter image description here

Inspired by Tingting Zhao's Dual line plots with different range of x-axis Using ggplot2.


Viewing all articles
Browse latest Browse all 18

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>