[Matplotlib-users] Help needed to fill_between two curves

Akhilesh Nautiyal akhilesh.phy at mnit.ac.in
Thu May 31 07:37:22 EDT 2018


Dear Adrien,
 Thanks again for your kindly help. My problem is solved. I could get the
plot I needed, which is attached here. I had to plot one more data file and
had to use two fill_between calls.

Regards,
akhilesh

On Wed, May 30, 2018 at 7:23 AM, vincent.adrien at gmail.com <
vincent.adrien at gmail.com> wrote:

> Akhilesh,
>
> I am not totally sure that I understand what is your remaining issue. To
> me, it seems that it is just a matter of building the “correct” common
> abscissa vector to pass to ``fill_between``. See for example the attached
> snippet for another kind of abscissa vector that would be possible and
> maybe better suited to what you want.
>
> Regards,
> Adrien
>
> On 05/28/2018 10:50 PM, Akhilesh Nautiyal wrote:
>
>> Dear Adrien,
>>
>>     Thanks a lot for your kind help. With this I am getting an extra
>> filled region as the abscissa of N_46 is getting extended. I will try to
>> play around with this to find some solution.
>>
>> Regards,
>> akhilesh
>>
>> On Fri, May 25, 2018 at 6:10 PM, vincent.adrien at gmail.com <mailto:
>> vincent.adrien at gmail.com> <vincent.adrien at gmail.com <mailto:
>> vincent.adrien at gmail.com>> wrote:
>>
>>     Hi Akhilesh,
>>
>>     Then I guess that you need to somehow interpolate your data to share
>>     the same abscissa values, at least for the “fill between” step. I am
>>     not very used to do this kind of things but please find attached a
>>     script that may be helpful to you (it produces to attached PNG, with
>>     Matplotlib 2.2). It uses Numpy to perform linear interpolation of
>>     your data; scipy.interpolate may also be a good source of
>>     interpolation tools if this is not good enough for you.
>>
>>     Best,
>>     Adrien
>>
>>     PS : I also reattach the data files, to make it easier to play with
>>     the script if somebody else wanted to propose a better solution.
>>
>>     On 05/25/2018 03:44 AM, Akhilesh Nautiyal wrote:
>>
>>         Dear Adrien,
>>
>>                    Thanks for the reply. I have tried all that. Actually
>>         in my case the two  curves have different size of abscissa and
>>         ordinates.  Suppose I make arrays like x1, y1 and x2, y2 from
>>         two data files
>>         attached in my previous mail, the arrays x1 and x2 have
>>         different size and the arrays y1 and y2 have different size.
>>         I will be grateful if you can help me how to fill the area
>>         between these curves n this particular case.
>>
>>         With Regards,
>>         akhilesh
>>
>>         On Thu, May 24, 2018 at 10:24 PM, vincent.adrien at gmail.com
>>         <mailto:vincent.adrien at gmail.com>
>>         <mailto:vincent.adrien at gmail.com
>>         <mailto:vincent.adrien at gmail.com>> <vincent.adrien at gmail.com
>>         <mailto:vincent.adrien at gmail.com>
>>         <mailto:vincent.adrien at gmail.com
>>
>>         <mailto:vincent.adrien at gmail.com>>> wrote:
>>
>>              Hi Akhliesh,
>>
>>              For basic usage of Matpolotlib, the following tutorials may
>>         be good
>>              starting points:
>>                 *
>>         https://matplotlib.org/tutorials/introductory/pyplot.html
>>         <https://matplotlib.org/tutorials/introductory/pyplot.html>
>>              <https://matplotlib.org/tutorials/introductory/pyplot.html
>>         <https://matplotlib.org/tutorials/introductory/pyplot.html>>
>>                 *
>>         https://matplotlib.org/tutorials/introductory/usage.html
>>         <https://matplotlib.org/tutorials/introductory/usage.html>
>>              <https://matplotlib.org/tutorials/introductory/usage.html
>>         <https://matplotlib.org/tutorials/introductory/usage.html>>
>>              To enforce peculiar x- and y-ranges, I think that you may
>>         want to
>>              use `ax.set_xlim` and `ax.set_ylim` (or `plt.xlim` and
>>         `plt.ylim` if
>>              you prefer the interactive Pyplot interface rather than the
>>              object-oriented one).
>>
>>              Besides, you may find the following example useful:
>>         https://matplotlib.org/gallery/lines_bars_and_markers/fill_
>> between_demo.html
>>         <https://matplotlib.org/gallery/lines_bars_and_markers/fill_
>> between_demo.html>
>>                     <https://matplotlib.org/galler
>> y/lines_bars_and_markers/fill_between_demo.html
>>         <https://matplotlib.org/gallery/lines_bars_and_markers/fill_
>> between_demo.html>>
>>              to learn how to fill the aerea between 2 curves.
>>
>>              Hopefully this will help you a bit.
>>
>>              Best regards,
>>              Adrien
>>
>>              On 05/24/2018 05:13 AM, Akhilesh Nautiyal wrote:
>>
>>                  Dear Sir/Madam,
>>
>>                                       I am plotting with matplotlib
>>         using two
>>                  data files with different x and y ranges. I need to
>>         fill up the
>>                  region between the two curves. I request you to kindly
>>         help me
>>                  in this regard. I am attaching the files with
>>                  this e-mail. the plot range should be between x->0.93
>>         to 1.0 and
>>                  y->0 to 0.25.
>>
>>                  Thanking you,
>>                  Sincerely,
>>                  akhliesh
>>
>>                  --                 *****************************
>> ******************************************************************
>>                  *    Dr. Akhilesh Nautiyal
>>                  *   Assistant Professor
>>                  *   Department of Physics
>>                  *   Malaviya National Institute of Technology Jaipur
>>                  *   JLN Marg Jaipur-302017
>>                  *    Mo: +91-9 <tel:%2B91-9445520847>549657939
>>                         ******************************
>> *****************************************************************
>>
>>
>>                  This body part will be downloaded on demand.
>>
>>
>>
>>
>>
>>         --         *****************************
>> ******************************************************************
>>         *    Dr. Akhilesh Nautiyal
>>         *   Assistant Professor
>>         *   Department of Physics
>>         *   Malaviya National Institute of Technology Jaipur
>>         *   JLN Marg Jaipur-302017
>>         *    Mo: +91-9 <tel:%2B91-9445520847>549657939
>>         ************************************************************
>> ***********************************
>>
>>
>>
>>
>>
>> --
>> ************************************************************
>> ***********************************
>> *    Dr. Akhilesh Nautiyal
>> *   Assistant Professor
>> *   Department of Physics
>> *   Malaviya National Institute of Technology Jaipur
>> *   JLN Marg Jaipur-302017
>> *    Mo: +91-9 <tel:%2B91-9445520847>549657939
>> ************************************************************
>> ***********************************
>>
>
>


-- 
***********************************************************************************************
*    Dr. Akhilesh Nautiyal
*   Assistant Professor
*   Department of Physics
*   Malaviya National Institute of Technology Jaipur
*   JLN Marg Jaipur-302017
*    Mo: +91-9 <%2B91-9445520847>549657939
***********************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180531/8055f263/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filled_region.png
Type: image/png
Size: 24789 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180531/8055f263/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filling.py
Type: text/x-python
Size: 1435 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180531/8055f263/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ns_r_N_46.dat
Type: application/octet-stream
Size: 8770 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180531/8055f263/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ns_r_N_46_55.dat
Type: application/octet-stream
Size: 7 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180531/8055f263/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ns_r_N_55.dat
Type: application/octet-stream
Size: 10149 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180531/8055f263/attachment-0005.obj>


More information about the Matplotlib-users mailing list