Adding images to figures in screen units

Helllo,
What is the correct way to add a background image to a plot using “screen” coordinates instead of “data” coordinates in Bokeh 0.12? When I try the following, it still seems to be using data coordinates.

p = figure(x_range=[5, 10], y_range=[-1, 1], x_axis_type='log')
image_source = ColumnDataSource(
            dict(url=[url],
            x=[0], y=[0], w=[200], h=[100],
            w_units=["screen"], h_units=["screen"])
    )
bkgimage = ImageURL(url="url", x="x", y="y", anchor="bottom_left",
                    global_alpha=0.2, w="w", h="h",
                    w_units="screen", h_units="screen")
p.add_glyph(image_source, bkgimage)

I expected to be able to set w_units="w_units", h_units="h_units" in my call to ImageURL, but this just gives an error
(ValueError: invalid value: 'w_units'; allowed values are screen or data).

Cheers,

Christian

I had to correct your code to make it runnable, but I never saw that error. I was able to set w_units and h_units
to “screen”.

                        Having said

that, it didn’t seem to be respecting th em as screen
units. I su ggest
open ing an
issue.

···

On 8/16/16 4:09 AM, Christian Hill
wrote:

Helllo,

      What is the correct way to add a background image to a plot

using “screen” coordinates instead of “data” coordinates in
Bokeh 0.12? When I try the following, it still seems to be
using data coordinates.

p = figure(x_range=[5, 10], y_range=[-1, 1], x_axis_type='log')
image_source = ColumnDataSource(
            dict(url=[url],
            x=[0], y=[0], w=[200], h=[100],
            w_units=["screen"], h_units=["screen"])
    )
bkgimage = ImageURL(url="url", x="x", y="y", anchor="bottom_left",
                    global_alpha=0.2, w="w", h="h",
                    w_units="screen", h_units="screen")
p.add_glyph(image_source, bkgimage)

I expected to be able to set w_units="w_units", h_units="h_units" in my call to ImageURL, but this just gives an error
(
ValueError: invalid value: 'w_units'; allowed values are screen or data).

Cheers,

Christian

  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/CABtdkq4wSy5kz6j8uqB%2BX61s6Ko0qJcwZthOH%2Bq%3D84HX%2BqLe%2BA%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CABtdkq4wSy5kz6j8uqB%2BX61s6Ko0qJcwZthOH%2Bq%3D84HX%2BqLe%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

Thanks, Sarah, I guess I’ll raise a bug report on this. The error I got happened when I tried:

image_source = ColumnDataSource(
            dict(url=[url],
            x=[0], y=[0], w=[200], h=[100],
            w_units=["screen"], h_units=["screen"])
    )
bkgimage = ImageURL(url="url", x="x", y="y", anchor="bottom_left",
                    global_alpha=0.2, w="w", h="h",
                    w_units="w_units", h_units="h_units")

working purely by analogy with the other arguments to ImageURL since the documentation is somewhat lacking around how this part of the API is supposed to work (probably as a consequence of the fact that it doesn’t).

Best wishes,

Christian

···

On 16 August 2016 at 21:33, Sarah Bird - Continuum [email protected] wrote:

I had to correct your code to make it runnable, but I never saw that error. I was able to set w_units and h_units
to “screen”.

                        Having said

that, it didn’t seem to be respecting th em as screen
units. I su ggest
open ing an
issue.

  On 8/16/16 4:09 AM, Christian Hill

wrote:

Helllo,

      What is the correct way to add a background image to a plot

using “screen” coordinates instead of “data” coordinates in
Bokeh 0.12? When I try the following, it still seems to be
using data coordinates.

p = figure(x_range=[5, 10], y_range=[-1, 1], x_axis_type='log')
image_source = ColumnDataSource(
            dict(url=[url],
            x=[0], y=[0], w=[200], h=[100],
            w_units=["screen"], h_units=["screen"])
    )
bkgimage = ImageURL(url="url", x="x", y="y", anchor="bottom_left",
                    global_alpha=0.2, w="w", h="h",
                    w_units="screen", h_units="screen")
p.add_glyph(image_source, bkgimage)

I expected to be able to set w_units="w_units", h_units="h_units" in my call to ImageURL, but this just gives an error
(
ValueError: invalid value: 'w_units'; allowed values are screen or data).

Cheers,

Christian

  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/CABtdkq4wSy5kz6j8uqB%2BX61s6Ko0qJcwZthOH%2Bq%3D84HX%2BqLe%2BA%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CABtdkq4wSy5kz6j8uqB%2BX61s6Ko0qJcwZthOH%2Bq%3D84HX%2BqLe%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

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/bac8f3b1-456d-0cde-93cb-ce08333605bd%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

My book, Learning Scientific Programming with Python is published by CUP
scipython.com: | @scipython3

w_units and h_units do not accept a “DataSpec” argument - that is a
column of a datasource, they only accept the value “string” or
“data”.

For reference:
···

http://bokeh.pydata.org/en/latest/docs/reference/models/glyphs.html#bokeh.models.glyphs.ImageURL.h_units

  On 8/17/16 7:14 AM, Christian Hill

wrote:

        Thanks, Sarah, I guess I'll raise a bug report on this.

The error I got happened when I tried:

image_source = ColumnDataSource(
            dict(url=[url],
            x=[0], y=[0], w=[200], h=[100],
            w_units=["screen"], h_units=["screen"])
    )
bkgimage = ImageURL(url="url", x="x", y="y", anchor="bottom_left",
                    global_alpha=0.2, w="w", h="h",
                    w_units="w_units", h_units="h_units")
        working purely by analogy with the other arguments to

ImageURL since the documentation is somewhat lacking around
how this part of the API is supposed to work (probably as a
consequence of the fact that it doesn’t).

Best wishes,

Christian

      On 16 August 2016 at 21:33, Sarah Bird
                    I

had to correct your code to make it runnable, but I never saw that error. I was able to
set w_units and h_units to
“screen”.

                                  Having said

that, it didn’t seem to be respecting th em as
screen units. I su ggest
open ing
an issue.

On 8/16/16 4:09 AM, Christian Hill wrote:

Helllo,

                    What is the correct way to add a background

image to a plot using “screen” coordinates
instead of “data” coordinates in Bokeh 0.12?
When I try the following, it still seems to be
using data coordinates.

p = figure(x_range=[5, 10], y_range=[-1, 1], x_axis_type='log')
image_source = ColumnDataSource(
            dict(url=[url],
            x=[0], y=[0], w=[200], h=[100],
            w_units=["screen"], h_units=["screen"])
    )
bkgimage = ImageURL(url="url", x="x", y="y", anchor="bottom_left",
                    global_alpha=0.2, w="w", h="h",
                    w_units="screen", h_units="screen")
p.add_glyph(image_source, bkgimage)

I expected to be able to set w_units="w_units", h_units="h_units" in my call to ImageURL, but this just gives an error
(
ValueError: invalid value: 'w_units'; allowed values are screen or data).

Cheers,

Christian

            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/CABtdkq4wSy5kz6j8uqB%2BX61s6Ko0qJcwZthOH%2Bq%3D84HX%2BqLe%2BA%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CABtdkq4wSy5kz6j8uqB%2BX61s6Ko0qJcwZthOH%2Bq%3D84HX%2BqLe%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer).

            For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

                  [ ![Continuum
                      Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png) ](http://continuum.io)
            --

            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/bac8f3b1-456d-0cde-93cb-ce08333605bd%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/bac8f3b1-456d-0cde-93cb-ce08333605bd%40continuum.io?utm_medium=email&utm_source=footer).

            For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).
    --
                My book, Learning Scientific

Programming with Python is published by CUP

                [scipython.com](http://scipython.com)                    :

| @scipython3

  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/CABtdkq6nje3D%2BjSBkgeUN_CqsAZst%2B7hSknHvP0W1fj40vz3zQ%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CABtdkq6nje3D%2BjSBkgeUN_CqsAZst%2B7hSknHvP0W1fj40vz3zQ%40mail.gmail.com?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

Thanks for the link. It seems a little odd that the numbers are part of the datasource but not the units that the numbers are in… Anyway, I’ve raised an issue on github and maybe someone who knows more about the Bokeh API than I do can take a look.

Best wishes,

Christian

···

On 18 August 2016 at 01:12, Sarah Bird - Continuum [email protected] wrote:

w_units and h_units do not accept a "DataSpec" argument - that is a

column of a datasource, they only accept the value “string” or
“data”.

For reference:

http://bokeh.pydata.org/en/latest/docs/reference/models/glyphs.html#bokeh.models.glyphs.ImageURL.h_units

  On 8/17/16 7:14 AM, Christian Hill

wrote:

        Thanks, Sarah, I guess I'll raise a bug report on this.

The error I got happened when I tried:

image_source = ColumnDataSource(
            dict(url=[url],
            x=[0], y=[0], w=[200], h=[100],
            w_units=["screen"], h_units=["screen"])
    )
bkgimage = ImageURL(url="url", x="x", y="y", anchor="bottom_left",
                    global_alpha=0.2, w="w", h="h",
                    w_units="w_units", h_units="h_units")
        working purely by analogy with the other arguments to

ImageURL since the documentation is somewhat lacking around
how this part of the API is supposed to work (probably as a
consequence of the fact that it doesn’t).

Best wishes,

Christian

  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/CABtdkq6nje3D%2BjSBkgeUN_CqsAZst%2B7hSknHvP0W1fj40vz3zQ%40mail.gmail.com.

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

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/4268ceac-a975-d982-1db5-ad40a83485f8%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

      On 16 August 2016 at 21:33, Sarah Bird
                    I

had to correct your code to make it runnable, but I never saw that error. I was able to
set w_units and h_units to
“screen”.

                                  Having said

that, it didn’t seem to be respecting th em as
screen units. I su ggest
open ing
an issue.

On 8/16/16 4:09 AM, Christian Hill wrote:

Helllo,

                    What is the correct way to add a background

image to a plot using “screen” coordinates
instead of “data” coordinates in Bokeh 0.12?
When I try the following, it still seems to be
using data coordinates.

p = figure(x_range=[5, 10], y_range=[-1, 1], x_axis_type='log')
image_source = ColumnDataSource(
            dict(url=[url],
            x=[0], y=[0], w=[200], h=[100],
            w_units=["screen"], h_units=["screen"])
    )
bkgimage = ImageURL(url="url", x="x", y="y", anchor="bottom_left",
                    global_alpha=0.2, w="w", h="h",
                    w_units="screen", h_units="screen")
p.add_glyph(image_source, bkgimage)

I expected to be able to set w_units="w_units", h_units="h_units" in my call to ImageURL, but this just gives an error
(
ValueError: invalid value: 'w_units'; allowed values are screen or data).

Cheers,

Christian

            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/CABtdkq4wSy5kz6j8uqB%2BX61s6Ko0qJcwZthOH%2Bq%3D84HX%2BqLe%2BA%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CABtdkq4wSy5kz6j8uqB%2BX61s6Ko0qJcwZthOH%2Bq%3D84HX%2BqLe%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer).

            For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

                  [ ![Continuum
                      Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png) ](http://continuum.io)
            --

            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/bac8f3b1-456d-0cde-93cb-ce08333605bd%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/bac8f3b1-456d-0cde-93cb-ce08333605bd%40continuum.io?utm_medium=email&utm_source=footer).

            For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).
    --
                My book, Learning Scientific

Programming with Python is published by CUP

                [scipython.com](http://scipython.com)                    :

| @scipython3

My book, Learning Scientific Programming with Python is published by CUP
scipython.com: | @scipython3