A colored bar plot with colors proportional to bar heights. In this case we let the plot limits be determined from data. We also plot a colorbar by using the colorbar=true option.
Example showing how to plot bar groups and at same time assign variable transparency to each of the group’s band usinf the fillalpha option. Here, each row on the input data represents a bar group that has as many bands as n_columns - 1. -1 because first column must hold the xx coordinates of each group. The colors come from the automatic cyclic scheme.
And we can also make plots with bar groups where each group has a variable number of bars. For that, pass NaN’s in place of the missing bars for a particular group. For example:
Next example shows how to plot error bars in a grouped bar. Similar to this mapplotlib’s example (labels will come later).
usingGMTbar(1:5, [2025; 3532; 3034; 3520; 2725], width=0.7, fill=["lightblue", "brown"], error_bars=(y=[23; 35; 42; 13; 23],), xticks=(:G1, :G2, :G3, :G4, :G5), yaxis=(annot=5,label=:Scores), frame=(title="Scores by group and gender", axes=:WSrt), show=true)
Example of a verticaly stacked bar plot. In this exampled we pass the xx coordinates as first argument and the individual bar heights in a matrix with smae number of rows as the number of elements in the x vector. To make it plot a stracked bar we used the option stacked=true.
usingGMT#Create a 3x3 gridG =gmt("grdmath -R0/2/0/2 -I1 X Y R2 NEG EXP X MUL =");# Plot that grid as 3D prismsbar3(G, # 'G' is the grid created above fill=[0,115,190], # Fill prisms with this RGB color lw=:thinnest, # Line thickness (0.25 pt) show=true) # Display the figure.
┌ Warning: 'multile coluns' in 3D plots are not allowed. Ignoring.
└ @ GMT C:\Users\j\.julia\dev\GMT\src\psxy.jl:521
Plot a grid as 3D prisms.
usingGMTG = GMT.peaks(); # Create a 'peaks' gridcmap =grd2cpt(G); # Colormap with the grid's data rangebar3(G, # 'G' is the grid created above lw=:thinnest, # Line thickness (0.25 pt) color=cmap, # Paint the prisms with colormap computed from grid show=true) # Display the figure.