1

The program pastebinned below generates a plot that looks like: Original plot Pastebin: http://pastebin.com/wNgAG6K9

Basically, the program solves an equation for AA, and plots the values provided AA>0 and AA=/=0. The data is plotted using pcolormesh from 3 arrays called x, y and z (lines 57 - 59).

What I want to do:

I would like to plot a line around the boundary where the solutions go from zero (black) to non-zero (yellow/green), see plot below. What is the most sensible way to go about this?

I.e. lines in red (done crudely in MS paint)

enter image description here

Further info: I need to be able to store the red dashed boundary values so that I can plot the red dashed boundary condition to another 2d plot made from real/measured/non-theoretical data.

Feel free to ask for further information.

8765674
  • 1,234
  • 4
  • 17
  • 32

1 Answers1

1

Without seeing your data, I would suggest first trying to work with matplotlib's internal algorithm to plot the contour line corresponding to the zero level. This is simple, but it might happen that the interpolation that is used for this doesn't look good enough (I don't know if it can find that sharp peak in the contour line). The proof of the pudding is in the eating:

plt.contour(x,y,z,[0],colors='r',linewidths=2,linestyles='dashed')

If that doesn't suffice, you might have to resort to image processing methods to find the boundaries of your data (after turning it into binary).

  • Thanks for the idea, but unfortunately this will not work. I want to be able to later apply the red dashed boundary line to another plot made from real data. The red dashed line data therefore needs to be stored in some kind of array for later plotting over another 2d plot.This means that there's no use in using image processing too. – 8765674 Oct 01 '16 at 19:35
  • 1
    @8765674 you can extract the contour line data. You have to get your hands dirty, [but it's not too hard](http://stackoverflow.com/questions/25873681/matplotlib-contour-plot-labels-overlap-axes/35615476#35615476) (or see [this other answer of mine](http://stackoverflow.com/questions/35633421/how-to-remove-omit-smaller-contour-lines-using-matplotlib/35664089#35664089)) – Andras Deak -- Слава Україні Oct 01 '16 at 19:53
  • 1
    I'll have a stab at this now. Thanks @Andras Deak – 8765674 Oct 01 '16 at 20:00
  • 1