-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanest way of plotting columns of a matrix (or multiple functions) #529
Comments
duplicate of #526. Gadfly works best with stacked DataFrames, rather than two dimensional matrices. There is a workaround with layers as described in the above issue. But that is not perfect. The best way to do what you need, with the functions defined above, is to convert your data into a DataFrame. df=DataFrame(n=repeat([1:10], outer=[3]),
y=vcat([x(n) for n=1:10],[y1(n) for n=1:10], [y2(n) for n=1:10]),
fun=repeat(["x", "y1", "y2"], inner=[10]))
plot(df, color="fun", x="n", y="y", Geom.point, Geom.line) |
I understood we don't have a clean call to achieve what I've asked with Gadfly. @aviks, why you closed the issue then? |
The cleanest (methodical) solution I could come up with so far is: df1 = DataFrame(x=1:10, y=f(1:10), label="f(x)")
df2 = DataFrame(x=1:10, y=g(1:10), label="g(x)")
# ...
df = vcat(df1, df2, ...)
plot(df, x=:x, y=:y, color=:label, Geom.line) It doesn't require all those trick calls to However, it would be nice to plot functions directly without this intermediate creation of dataframes. |
Sorry for my previous comment from my iPhone. The format was distoried and that message was unreadable. I recommend
|
Hi @juliohm Yes, there may not be clean way to do that, but I closed this issue because the same thing is being discussed in issue number #526 , which I'd linked to in my comment. Let me know if you disagree, and I'll re-open this. Thanks @zhujinxuan . |
Thanks @aviks, it's okay to close this as duplicate. |
I was not able to find an answer to this simple question in the docs. Let's say I have a matrix such that the first column has the abscissas in the x axis and the other columns are functions evaluated at these abscissas. How do I plot all columns at once in different color and with a legend?
Alternatively, suppose I have three functions:
How do I plot
x vs. y1
andx vs. y2
in different color with a legend varying n=1:10?The text was updated successfully, but these errors were encountered: