简体   繁体   中英

Polar Plots in Julia

I came across a Rose plot obtained with Plots.jl package in Julia:

https://goropikari.github.io/PlotsGallery.jl/src/rose.html

Two things are not clear to me. The first one is what is Julia doing on the line:

θ = 0:2pi/n:2pi

It seems that the output is (lower limit):(bin size):(upper limit) but I haven't seen this type of arithmetics previously where two ranges are divided. The second thing is that I would like to obtain a histogram polar plot as it was done with R ( Making a polar histogram in ggplot2 ), but I haven't found the documentation for line styles or how to do it in Plots.jl . Thanks.

Note that start:step:end is a common syntax in creating ranges. Let's dissect the line:

# `pi` is a reserved variable name in Julia 
julia> pi
π = 3.1415926535897...

# A simple division
julia> 2pi/1
6.283185307179586

# Simple multiplication
julia> 2pi
6.283185307179586

So the 0:2pi/n:2pi creates an object of type StepRange that starts from 0 up to 2pi with steps of size 2pi/n .
In the case of desired plot, you can use the PlotlyJS.jl package. As they provided an example here . (Scroll down until you see "Polar Bar Chart")
I tested the code myself, and it's reproducible expectedly. Unfortunately, I don't know anything about the R language.

julia> using RDatasets, DataFrames, PlotlyJS

julia> df = RDatasets.dataset("datasets", "iris");

julia> sepal = df.SepalWidth;

julia> plot(
           barpolar(
               r=sepal
           )
       )

Results in:
在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM