Hi there. I have a plot with two different series (a scatterline and a fillrange). I want the fillrange (representing error) to be of the same color as the line.
Here is my code:
using DataFrames, Plots, Random
Random.seed!(12345)
test_data = DataFrame(
[1:100, rand(100), sample(['A', 'B',], 100)],
[:Image_no, :val1, :category]
)
test_data.val_lo = test_data.val1 .- 0.1
test_data.val_hi = test_data.val1 .+ 0.1;
first(test_data, 5)
5 rows × 5 columns
Image_no val1 category val_lo val_hi
Int64 Float64 Char Float64 Float64
1 1 0.791805 B 0.691805 0.891805
2 2 0.159579 A 0.059579 0.259579
3 3 0.334191 B 0.234191 0.434191
4 4 0.811392 B 0.711392 0.911392
5 5 0.796629 A 0.696629 0.896629
plot(
test_data.Image_no, test_data.val1, group=test_data.category,
marker=:o, lw=1.5,
)
plot!(
test_data.Image_no, test_data.val_lo, group=test_data.category,
fillrange=test_data.val_hi,
alpha=0.5,
)
Plots.jl uses the next colors of the color cycle of the palette for the fillranges, so that the colors do not match with those of the scatterline.
I have tried using different colors for the color
or seriescolor
arguments. For example I tried [1, 2]
to select the first two colors of the palette, or i tried
using ColorSchemes
colors = ColorSchemes.tab10[1:2]
plot(..., color_palette=colors)
But none of this leads to my desired output (fillrange and line of the same color, but cycling through colors for each category).