3

Say I have these labels:

hv.Labels((stops['x'], stops['y'], labels))

How do I rotate the text by n degrees? I would imagine it to be something like this:

hv.Labels((stops['x'], stops['y'], labels), rotation=45)

Similar to this question. It seems like the bokeh Text glyph has an angle property but I've been struggling to figure out what goes on behind the scenes.

ricefarmer369
  • 63
  • 2
  • 8

2 Answers2

3

You can use the xrotation = 90 option as demonstrated in this example http://holoviews.org/gallery/demos/bokeh/lesmis_example.html#bokeh-gallery-lesmis-example

And here is the guide on how to set options http://holoviews.org/getting_started/Customization.html

obust
  • 63
  • 1
  • 4
1

There are different options

  • on the object you can specify the option "plot" with a dict (where you can define general plt properties like the height and width of the plot or xrotation and yrotation .. )

  • if you use an overlay you can specify it in there

  • in Jupyter(Lab) you can set the option (for Curve, Scatter or Overlay) as first code in the cell

import:

import holoviews as hv
from holoviews import dim, opts
hv.extension('bokeh', 'matplotlib')

example:

#%%opts Scatter [width=800, height=450, xrotation= 35, ]
macro_df = pd.read_csv('http://assets.holoviews.org/macro.csv', '\t')
key_dimensions   = [('year', 'Year'), ('country', 'Country')]
value_dimensions = [('unem', 'Unemployment'), ('capmob', 'Capital Mobility'),('gdp', 'GDP Growth'), ('trade', 'Trade')]
macro = hv.Table(macro_df, key_dimensions, value_dimensions)
gdp_curves = macro.to.curve('Year', 'GDP Growth')
gdp_unem_scatter = macro.to.scatter('Year', ['GDP Growth', 'Unemployment'])

(gdp_curves * gdp_unem_scatter ).opts( 
   opts.Curve( color='k' ), 
   opts.Scatter(cmap='Blues', color='Unemployment', line_color='k', size=dim('Unemployment')*1.5),    
   opts.Overlay(height=500, width=800, show_frame=False, xrotation= 35, yrotation= 10, ),
   #plot=dict(width=500, height=500, xrotation= 35),   
)

enter image description here

InLaw
  • 2,537
  • 2
  • 21
  • 33