☰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

Hide Text Strings on Graph

Community Support
Armen_Alexanian
Armen_Alexanian

Hi,

On my graph there are strings which print inside boxes in a rectangle. Sometimes the strings are too long and other times the value is null (which show up as NaN) and I’d like to hide (not print) those so they don’t show up on the graph. Is there a way to avoid printing certain strings? I can’t change the color because since the graph has multiple colored boxes, there’re no backgrounds against which white strings would appear hidden.

Thanks very much!

Armen

⌁   Link to post
Armen_Alexanian
Armen_Alexanian

I answered my own question. Inside the column data source, you can append the fillna(“”) function which allows you to change NaN to a zero-length string. You can see I still have a lot to learn!

source = ColumnDataSource(

data = dict(

unit_order = leases[‘unit_order’],

floor_number = leases[‘floor_number’],

.

.

.

unit_f = leases[‘unit_f’].fillna(“”),

display_value = leases[‘display_value’].fillna(“”)

)

)

···

On Tuesday, August 5, 2014 12:22:24 PM UTC-7, Armen Alexanian wrote:

Hi,

On my graph there are strings which print inside boxes in a rectangle. Sometimes the strings are too long and other times the value is null (which show up as NaN) and I’d like to hide (not print) those so they don’t show up on the graph. Is there a way to avoid printing certain strings? I can’t change the color because since the graph has multiple colored boxes, there’re no backgrounds against which white strings would appear hidden.

Thanks very much!

Armen

⌁   Link to post
Damian_Avila
Damian_Avila

A user that answered himself… nice :wink:
Thanks for the question… and the answer!

Damian

···

On Wed, Aug 6, 2014 at 2:32 PM, Armen Alexanian armenalexanian@gmail.com wrote:

I answered my own question. Inside the column data source, you can append the fillna(“”) function which allows you to change NaN to a zero-length string. You can see I still have a lot to learn!

source = ColumnDataSource(

data = dict(

unit_order = leases[‘unit_order’],

floor_number = leases[‘floor_number’],

.

.

.

unit_f = leases[‘unit_f’].fillna(“”),

display_value = leases[‘display_value’].fillna(“”)

)

)

On Tuesday, August 5, 2014 12:22:24 PM UTC-7, Armen Alexanian wrote:

Hi,

On my graph there are strings which print inside boxes in a rectangle. Sometimes the strings are too long and other times the value is null (which show up as NaN) and I’d like to hide (not print) those so they don’t show up on the graph. Is there a way to avoid printing certain strings? I can’t change the color because since the graph has multiple colored boxes, there’re no backgrounds against which white strings would appear hidden.

Thanks very much!

Armen

–

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/f87fd6c4-551e-40c6-8d26-da6d0c251b7e%40continuum.io.

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

⌁   Link to post
Bryan
Bryan

Armen,

I am glad you found a workaround. As another suggestions I will also mention that it is possible to set the alpha value in a vectorized fashion, so you could make the alpha zero for the values you don't want to show, this will cause them not to be visible. I think your solution is even cleaner, though. It sounds like we might need to take a look at the json encoder, I am not sure that "null" values should render as "NaN".

Bryan

···

On Aug 6, 2014, at 6:32 PM, Armen Alexanian <armenalexanian@gmail.com> wrote:

I answered my own question. Inside the column data source, you can append the fillna("") function which allows you to change NaN to a zero-length string. You can see I still have a lot to learn!

source = ColumnDataSource(
    data = dict(
        unit_order = leases['unit_order'],
        floor_number = leases['floor_number'],
  .
  .
  .
        unit_f = leases['unit_f'].fillna(""),
        display_value = leases['display_value'].fillna("")
    )
)

On Tuesday, August 5, 2014 12:22:24 PM UTC-7, Armen Alexanian wrote:
Hi,

On my graph there are strings which print inside boxes in a rectangle. Sometimes the strings are too long and other times the value is null (which show up as NaN) and I'd like to hide (not print) those so they don't show up on the graph. Is there a way to avoid printing certain strings? I can't change the color because since the graph has multiple colored boxes, there're no backgrounds against which white strings would appear hidden.

Thanks very much!
Armen

--
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/f87fd6c4-551e-40c6-8d26-da6d0c251b7e%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Armen_Alexanian
Armen_Alexanian

Thanks so much Bryan! :slight_smile:

···

On Wed, Aug 6, 2014 at 12:07 PM, Bryan Van de Ven bryan@bokeh.org wrote:

Armen,

I am glad you found a workaround. As another suggestions I will also mention that it is possible to set the alpha value in a vectorized fashion, so you could make the alpha zero for the values you don’t want to show, this will cause them not to be visible. I think your solution is even cleaner, though. It sounds like we might need to take a look at the json encoder, I am not sure that “null” values should render as “NaN”.

Bryan

On Aug 6, 2014, at 6:32 PM, Armen Alexanian armenalexanian@gmail.com wrote:

I answered my own question. Inside the column data source, you can append the fillna(“”) function which allows you to change NaN to a zero-length string. You can see I still have a lot to learn!

source = ColumnDataSource(

data = dict(
    unit_order = leases['unit_order'],
    floor_number = leases['floor_number'],
  .
  .
  .
    unit_f = leases['unit_f'].fillna(""),
    display_value = leases['display_value'].fillna("")
)

)

On Tuesday, August 5, 2014 12:22:24 PM UTC-7, Armen Alexanian wrote:

Hi,

On my graph there are strings which print inside boxes in a rectangle. Sometimes the strings are too long and other times the value is null (which show up as NaN) and I’d like to hide (not print) those so they don’t show up on the graph. Is there a way to avoid printing certain strings? I can’t change the color because since the graph has multiple colored boxes, there’re no backgrounds against which white strings would appear hidden.

Thanks very much!

Armen

–

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/f87fd6c4-551e-40c6-8d26-da6d0c251b7e%40continuum.io.

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

–

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/9A8928A5-0E35-4409-B90E-C5005E977707%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post

End of archived discussion · Replies are disabled