need to creat Pie Gauge Chart in Julia - plot

I need to design a Pie Gauge Chart for each JOB category. My data look like
BR PROG_JOB1 PROG_JOB2 PROG_JOB3
0 BR1 0.5 0.4 0.5
1 BR2 0.3 0.2 0.6
2 BR3 0.6 0.5 0.3
and I need to create Circular Gauge for each JOB progress. How should I do it in Julia
I have tried https://lumiamitie.github.io/r/pie-gauge-in-ggplot2/ by proj=:polar in Plots.jl, but doesn't solve it.
desired output

using StatisticalGraphics package:
using InMemoryDatasets
using StatisticalGraphics
ds=Dataset(BR=["BR1","BR2","BR3"],JOB1=[.5,.3,.6],JOB2=[.4,.2,.5],JOB3=[.5,.6,.3])
# data manipulation
ds2=transpose(gatherby(ds,:BR),r"JOB")
modify!(ds2,:_c1=>byrow(x->[x,1-x])=>:progress,:BR=>byrow(x->[x,missing])=>:cat)
flatten!(ds2,[:progress,:cat])
# plot
sgplot(
groupby(ds2,:_variables_),
Pie(category=:cat,response=:progress,group=:BR,innerradius=0.3, label=:percent,labelcolor=:white,colormodel=[:blue,:white,:orange,:green]),
layout=:row,headercolname=false,legend=false,width=200,height=200
)

You can draw it manually with GLMakie:
using GLMakie
pie([0.5, 0.5], color=[:green, :white], inner_radius=0.8, strokecolor=:white)
pie!([0.3, 0.7], color=[:orange, :white], inner_radius=0.6, radius=0.79, strokecolor=:white)
pie!([0.6, 0.4], color=[:blue, :white], inner_radius=0.4, radius=0.59, strokecolor=:white)

Related

Gnuplot: plotting results from different sources in one graph

I am trying to compare the results of a measurement from different collaborations using gnuplot. The plot should ideally look like this:
I can't figure out how to plot the different results one on top of the other, with the labels on the right. I would be really grateful if anyone could help me.
I show two approaches, depending of your data file. Two possible structures are data01.dat
# data01.dat
alpha error
1.0 0.2
2.0 0.2
1.5 0.2
or data02.dat
# data02.dat
Collab alpha error
1 1.0 0.2
2 2.0 0.2
3 1.5 0.2
Using the data01-structure:
reset
set encoding utf8
set terminal wxt size 480,600 font "Times New Roman,10"
set tics out nomirror
set xlabel "{/:Italic=12 α}"
set link y2
unset ytics
set y2range [:] reverse
set y2tics 1
set format y2 "Collaboration %g"
set offsets graph 0.1, 0.1, 0.5, 0.5
plot "data01.dat" u 1:0:2 w xerrorbars pt 7 not
Using the data02-structure almost all is the same, except the plot command.
plot "data02.dat" u 2:1:3 w xerrorbars pt 7 not
The results.
I hope be useful.

How to plot three coordinates in function of a fourth (3 positional coordinates in function of time) in R?

I would like to plot a 4 dimensional graph in R. I have three coordinates of position and a fourth variable (time). In this plot I would like to show these 3 coordinates in function of time. I only have one observation for each coordinate in each time. Somebody know if this is possible in R? I only found solutions for 3D plots.
For example:
coord_1<-c(0.5,0.3,0.9)
coord_2<-c(0.2,0.1,0.6)
coord_3<-c(0.7,0.4,0.8)
time_seg<-c(0.1,0.5,1)
data_plot<-data.frame(coord_1,coord_2,coord_3, time_seg)
data_plot
coord_1 coord_2 coord_3 time_seg
1 0.5 0.2 0.7 0.1
2 0.3 0.1 0.4 0.5
3 0.9 0.6 0.8 1.0

How to force color range in gnuplot

I'm using Gnuplot 4.6. I have data files each containing 3 columns of data: X coordinate, Y coordinate and temperature. I wish to make an animation of plots of temperature as a function of X and Y coordinates. For this I'm using the following script:
set pm3d map; set palette;
do for [n=0:200] {splot sprintf("Temperature.%04d.dbl", n) binary array=100:100:1 form="%double" title 'file number'.n}
My problem is with the fact that after a few plots, the distribution of colors changes, both in the plot and in the legend. This makes the reading from the graph really hard.
I consulted the following post:
gnuplot heat map color range
and since the range of the temperature variable is from 0.0 to 1.2 I thought to use:
set zrange [0.0:1.2]; set cbrange [0.0:1.2];
but it doesn't help and the temperature color continues to be autoscaled from plot to plot. Any suggestions?
In addition to setting cbrange, you could try defining your own palette by
set palette defined (0 "black",\
0.2 "red",\
0.4 "orange-red",\
0.6 "orange",\
0.8 "yellow",\
1.0 "light-green",\
1.2 "green")
Or if you want discrete values:
set palette defined (0 "black",\
0.2 "black",\
0.2 "red",\
0.4 "red",\
0.4 "orange-red",\
0.6 "orange-red",\
0.6 "orange",\
0.8 "orange",\
0.8 "yellow",\
1.0 "yellow",\
1.0 "light-green",\
1.2 "light-green")

How to change the contours and legend in mathematica contour plot?

The ContourPlot function in Mathematica automatically gets you a legend and contours with colors on the plot which are uniformly distributed ( for example, blue color from 0.1 to 0.2 function values, green from 0.2 to 0.3 and etc.) In my case, function, that I plot, has a large number of values in the 0.1 to 0.2 and only few from 0.2 to 1. If I want to distinguish better values from 0.1 to 0.2 and make several colors for this section, and make the values from 0.2 to 1 by one color, how should I do this?
I would use the Mathematica function Hue[z] to assign a color to your contours. To do this, you're going to use the option ColorFunction, like this:
ContourPlot[myFunction, {x,-10,10}, {y,-10,10}, ColorFunction -> Function[{f},Hue[g[f]]]]
In this code, g[f] is some function that maps the contour level to a hue (a value between 1 and 255). You said you wanted many values between 0 and 0.2, and only a few between 0.2 and 1, so I would use something like
g[f_] := 100*(5*f)^(1/4)
Obviously you can change this to fit. If this doesn't help, you may need to increase the number of contours, using the option Contours->n, where n is how many you want. Hope this helps!

Two Boxplots for one X position using gnuplot

I have 2 sets of data A and B, each with a y value for x=100, 200, 300. I want to create one graph which shows the difference between these two data sets. As such this means that for each x, there will be two boxplots(one for data A and one for data B).
for example, this is how the columns are organized in my data.
DataSet A
# x=100 200 300
1 2 3
1.1 2.1 3.1
1.2 2.2 3.2
1 2 3
1.01 2.01 3.01
DataSet B
# x=100 200 300
6 7 9
6.1 7.1 9.1
6.2 7.2 9.2
6 7 9
6.01 7.01 9.01
I was able to get two graphs out of this data using:
set style fill solid 0.25 border -1
set style boxplot outliers pointtype 7
set style data boxplot
set xtics ('100' 1, '200' 2, '300' 3)
plot for [i=1:3] "A.txt" using (i):i notitle
plot for [i=1:3] "B.txt" using (i):i notitle
However, I am facing issues when combining it into one.
Please help.
If you want to have them stacked above each other (in case they don't overlap), then you can just combine the two plot into one with
plot for [i=1:3] "A.txt" using (i):i notitle,\
for [i=1:3] "B.txt" using (i):i notitle
If they can overlap, you may want to put them side-by-side with
set boxwidth 0.3
plot for [i=1:3] "A.txt" using (i-0.15):i notitle,\
for [i=1:3] "B.txt" using (i+0.15):i notitle
Just to give two example of how you could combine those plots.

Resources