How to graph two sets of data with lines and two *different* point symbols with *readable* data point symbols in legend?

تعرفه تبلیغات در سایت

آرشیو مطالب

امکانات وب

Vote count: 0

I have been trying to plot a graph of two sets of data with different point symbols and connecting lines using the R package ggplot2, but I have not been able to get the legend correctly distinguish between the two curves, even though I have searched my elbow off to find out how to do it.

In the following code:

df <- data.frame( thrd_cnt=c(1,2,4,8,16),


    ggplot(data = df, aes(df$thrd_cnt, y=df$runtime, color=)) +
    geom_line(aes(y=df$runtime4, color = "4 cores")) +
    geom_point(aes(y=df$runtime4, color = "4 cores"), fill = "white", size = 3, shape = 21) +
    geom_line(aes(y=df$runtime8, color = "8 cores")) +
    geom_point(aes(y=df$runtime8, color = "8 cores"), fill = "white", size = 3, shape = 23) +
    xlab("Number of Threads") +
    ylab(substitute(paste("Execution Time, ", italic(milisec)))) +
    scale_x_continuous(breaks=c(1,2,4,8,16)) +
    theme(legend.position = c(0.3, 0.8)) +
    labs(color="# cores")

## save a pdf and a png
ggsave(paste0("runtime.pdf"), width=5, height=3.5)
ggsave("plot.png", width = 5, height = 3.5)

outputs this graph:


But the data point symbols in the legend are not distinguishable. The legend shows the same symbol for both graphs (which is both data point symbols on top of each other).

One possible solution is to define the number of threads as a factor, then I might be able to get the data point symbols on the legend right, but still I don't know how to do that.

Any help would be appreciated.

asked 43 secs ago

نویسنده : استخدام کار بازدید : 0 تاريخ : چهارشنبه 22 فروردين 1397 ساعت: 5:29
برچسب‌ها :



نام کاربري :
رمز عبور :