I have a list of Gadfly layers with an unknown size:
lines = [layer(x=x,y=i*x) for i in range(1,stop=3)]
Now I would like to draw all of them in one plot. But Gadfly expects a number of single layers, rather than a list of layers. So
plot(lines) doesn't work but plot(lines[1], lines[2], lines[3]) does.
In Python I'd just use the splat operator plot(*lines).
How can do something like this in Julia?
Try to splat it with ...
plot(lines...)
Related
In Julia I know one way of combining subplots as the this:
p1=plot(...)
p2=plot(...)
p3=plot(...)
plot(p1, p2, p3, layout(3,1))
However, suppose that I don't know beforehand the number of subplots, like when I generate the subplots based of some parameters passed to a function, then how would I accomplish the same thing?
What I tried was that I made an array to contain all the subplots
Plot_array=[p1, p2, p3]
(again, the number of elements of Plot_array can be changed based on what passed to a function)
and then
plot(Plot_array, layout=(...))
However, this did not work. Does anyone know any better way?
Something like this should work
plot(Plot_array..., layout=(length(Plot_array), 1))
Three dots is so called "splat" operator: https://docs.julialang.org/en/v1/manual/functions/#Varargs-Functions
Is there any way we can combine ggstatsplot::grouped_ggbetweenstats and facet_grid to get multiple plots in one scale, something like below?
data<-data.frame(technology=(a,a,a,a, b,b,b,b,c,c,c,c,d,d,d,d), rate=c(2,5,7,9,2,5,7,9,2,5,7,9,2,5,7,9),return=c(20,15,20,30,50,13,10,8,7,9,11,23,17,20,13,16))
In short, no, it is not possible to combine ggplot2::facet_grid() with ggstatsplot::grouped_ggbetweenstats() (or any grouped_ functions actually) because the latter doesn't output a ggplot object.
ggstatsplot uses a wrapper around cowplot::plot_grid() function (called combine_plots()) in the backdrop to arrange the individual plots and any adjustment you want to make to how individual plots are arranged in the combined plot can be made in the grouped_ function itself using ... argument.
For example, see the documentation for grouped_ggbetweenstats() function here-
https://indrajeetpatil.github.io/ggstatsplot/reference/grouped_ggbetweenstats.html#arguments
I am trying to produce a black-and-white network diagram using node symbols (point shapes) to differentiate node types, instead of using colors. However, I cannot find a way to do this using the gplot function in the package sna. Here's a simple example:
library(network)
library(sna)
set seed(100)
net <- as.network(matrix(sample(c(0:1),100,replace=TRUE),nrow=10,ncol=10))
symbols <- rep(c(1:2),5)
gplot(net,pch=symbols)
At least with my version of r and sna, gplot just ignores pch. I found documentation here which seems to indicate that at one point vertex.pch could be used to set node symbols. However, this is no longer in the sna documentation and the following code results in an error:
gplot(net,vertex.pch=symbols)
Is there a way to substitute symbols for colors in a network plot, ideally using gplot (I am trying to produce some black and white versions of existing color plots, so I'd rather not start from scratch if possible)?
gplot doesn't directly support pch, but it does let you change the number of sides in the vertex polygon using the vertex.sides argument. So if you wanted to draw your example with triangles and squares:
gplot(net,vertex.col='black',vertex.sides = symbols+2)
I found a vast number of libraries for plotting in Julia that includes the following:
Winston: 2D plotting for julia looks like it requires Cairo and Color. Examples look like it supports line plots, histograms, scatterplot, and regression.
Gadfly: Looks to support Dataframes and uses the Color library. Graphs has a fairly clean look to them. Supports boxplot, line plots, bar plots, histograms, scatter plots, regression, densities, and contours. Runs on vector graphics library Compose.jl
Pyplot: A wrapper for Matplotlib in python
Gaston: Basically a wrapper for GNUplot
Which graphing library is preferred for speed? Are one of the plots using a wrapper faster than the julia based ones?
I use Matplotlib so I am aware it is not the fastest, but has a lots of features. It seems like Gadfly would be the prefer julia based plotting library due to its ability to plot different graphs, is it customizable as matplotlib in terms of being able to control line thickness, point shapes, create dotted lines?
Speed is a tough question to answer because it depends strongly on exactly what you are plotting, and what you are plotting to. There is not a fastest overall.
Gadfly has the best interface, I think, because it is in Julia and is written for Julia. Compose is also very powerful in its own right (see, e.g. graph plotting).
For publication-quality plots though, I feel you still need to use PyPlot/matplotlib. It has more control over how the plot appears - e.g. right now Gadfly doesn't support different dashed lines. I find myself using Gadfly where possible, and using PyPlot for more "final" graphics for black-and-white publication purposes.
Is it possible to have different colours in my plot in Scilab? I use the mtlb_hold to hold the graph and it works fine, but my problem is that then I have the same colours in my graph. In Matlab with the hold command, I have different colours. Is it possible to have different colours in Scilab too?
Thank you in advance.
Just found it. In the plot function, for example plot(), you can pass a second argument which specifies the color that will be used. For example, you can use use b for blue color, g for green, r for red and call plot() like this: plot(z,"r").
The SciLab documentation provides examples for using colors:
https://help.scilab.org/doc/5.3.3/en_US/color.html
The plot2d()-function e.g. accepts an attribute style, where you can even specify a color for each function with its full name:
plot2d(x,[sin(x),cos(x)],style=[color("red"),color("green")]);