☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Contour Plot

Community Support
Oscar_Delgado
Oscar_Delgado

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)

⌁   Link to post
Bryan
Bryan

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 oscarjdm19@gmail.com 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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
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.

⌁   Link to post
Bryan
Bryan

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 <bryan@bokeh.org> 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 <oscarjdm19@gmail.com> 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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
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>

⌁   Link to post
Oscar_Delgado
Oscar_Delgado

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!

⌁   Link to post

End of archived discussion · Replies are disabled