Additionally, the column name might be used as the An example: using StatsPlots, RDatasets For data fields or certain attributes (such as group) a symbol will be replaced with the corresponding column(s) of the DataFrame. Using the StatsPlots extension package, you can pass a DataFrame as the first argument (similar to Gadfly or R's ggplot2). Plot!(other_rects, other_rects, label = "other group") "input_data_1.png" Plot(some_rects, some_rects, label = "some group") using Plotsįunction rectangle_from_coords(xb,yb,xt,yt) A call to plot would then draw one path with disjoints The following code draws n=4 rectangles in g=2 groups. To adress this, you can use NaN as a path separator. You'll end up with n groups in the legend, rather than g groups. While you can use plot to draw separate polygons with each call, you cannot group two separate plots back into a single group. Now, let's say you're plotting n polygons grouped into g groups, with n > g. You can use several calls to plot to draw several polygons. Plot() # array of tuples of arrays -> 2 series, plots each tuple as new series Unconnected Data within same groupsĪs shown in the examples, you can plot a single polygon by using a single call to plot using the :path line type. Plot(, ]) # array of array of arrays -> 4 series, plots each individual array, x assumed to be integer count Plot() # array of matrices -> 4 series, plots each matrix column, x assumed to be integer count The following example illustrates how Plots.jl handles: an array of matrices, an array of arrays of arrays and an array of tuples of arrays. This example plots the four series with different labels, marker shapes, and marker colors by combining row and column vectors to decorate the data. # Marker colors in a matrix: applies to series and data points # Marker shapes in a column vector: applies to data points # We put labels in a row vector: applies to each series The flexibility and power of this can be illustrated by the following piece of code: using Plotsĭata = The difference is that in the first example, it is a length-2 column vector, and in the second example it is a (1 × 2) row vector (a Matrix). However, scatter(rand(10,4), markershape = ) will create 4 series, with series 1 and 3 having markers shaped as :circle and series 2 and 4 having markers shaped as :rect (i.e. scatter(rand(10,4), markershape = ) will create 4 series, each assigned the markershape vector. This rule carries into keyword arguments. This follows a consistent rule… vectors apply to a series, matrices apply to many series. In most cases, passing a ( n × m) matrix of values (numbers, etc) will create m series, each with n data points. The reason lies in the flexibility of Julia's multiple dispatch, where every combination of input types can have unique behavior, when desired. plot(x, y): creates a 2D plot plot(x, y, z): creates a 3D plot The plot function has several methods: plot(y): treats the input as values for the y-axis and yields a unit-range as x-values. There are a few rules to remember, and you'll be a power user in no time. You shouldn't spend your time transforming and massaging your data into a specific format. Part of the power of Plots lies is in the many combinations of allowed input data.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |