Skip to content
Advertisement

fill between vertical curves in the sub plot

Dears, I have the following csv file

depth lst dol Anhd sst
50 20 40 80 100
100 25 50 85 100
150 15 35 75 100

I take the data from csv to draw subplot contains four curves in the same subplot, I have filled by red color from left edge to first curve, also I have filled by blue color from last curve to right edge, I want to fill between entire curves in between first and last curve and make color legend. the table is equal to csv file

JavaScript

Advertisement

Answer

Here is an approach looping through the curves, and using a variable previous_curve which contains the position of the previous curve. At the start, the previous curve is all zeros. Similarly, the name of the previous curve can be saved and used as a label for the fill. All labels will appear in the default legend.

The example code below uses a gridspec with only 4 columns, to make the example plot a bit clearer.

JavaScript

using fill_between_x for multiple curves

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement