Contour Plot

Good
morning,

I am trying
to create a Contour Plot to identify regions for simple ML classification
algorithms. The example I was following
was created with Matplotlib, but I believe bokeh images can do the trick (as
you can see in the attached notebook).

Initially,
it looks like both figures are the same, but if you look closer at the
boundaries you see that matplotlib has a steeper slope. As I am using exactly
the same data for both I am wondering if I did something wrong when creating
the bokeh image that result in this difference.

I will appreciate any thoughts.

Best!

Contour Plot.ipynb (1.96 MB)

The bounds of the image are evidently not being set correctly. Add a pan and zoom tool to the Bokeh plot and you can see that it is possible to zoom out and see more of the image. In terms of the literal visible slope, it also appears that the aspect ratio of the two plots are not identical.

Bryan

···

On Apr 12, 2016, at 8:15 AM, Oscar Delgado [email protected] wrote:

Good morning,

I am trying to create a Contour Plot to identify regions for simple ML classification algorithms. The example I was following was created with Matplotlib, but I believe bokeh images can do the trick (as you can see in the attached notebook).

Initially, it looks like both figures are the same, but if you look closer at the boundaries you see that matplotlib has a steeper slope. As I am using exactly the same data for both I am wondering if I did something wrong when creating the bokeh image that result in this difference.

I will appreciate any thoughts.

Best!


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9eaedc18-4b15-43b7-b7f5-ed38d412aef7%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

looking at your code, I expect this is the problem:

  dw=xx1.max()

because dw is the *width* of the image in data units. You probably want dw = (max-min)

Bryan

···

On Apr 12, 2016, at 8:47 AM, Bryan Van de Ven <[email protected]> wrote:

The bounds of the image are evidently not being set correctly. Add a pan and zoom tool to the Bokeh plot and you can see that it is possible to zoom out and see more of the image. In terms of the literal visible slope, it also appears that the aspect ratio of the two plots are not identical.

Bryan

<Screen Shot 2016-04-12 at 8.46.15 AM.png>

On Apr 12, 2016, at 8:15 AM, Oscar Delgado <[email protected]> wrote:

Good morning,

I am trying to create a Contour Plot to identify regions for simple ML classification algorithms. The example I was following was created with Matplotlib, but I believe bokeh images can do the trick (as you can see in the attached notebook).

Initially, it looks like both figures are the same, but if you look closer at the boundaries you see that matplotlib has a steeper slope. As I am using exactly the same data for both I am wondering if I did something wrong when creating the bokeh image that result in this difference.

I will appreciate any thoughts.

Best!

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9eaedc18-4b15-43b7-b7f5-ed38d412aef7%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<Contour Plot.ipynb>

Good morning Bryan,

Thanks a lot for the reply.

You are right, my problem was with the image setup. I changed the line to:

p.image(image=[Z], x=xx1.min(), y=xx2.min(), dw=xx1.max()-xx1.min(), dh=xx2.max()-xx2.min(), palette=“PuBu3”)

and add a second y-axis just to be sure:

p.extra_y_ranges = {“foo”: Range1d(start=xx2.min(), end=xx2.max())}

p.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

Now both contour plots (matplotlib/bokeh) are identical.

Again, thanks a lot.

Best!