I'm trying to change the x-axis on a plot to get ordinal text values and I'm having a hard time trying to find a workaround. Here is my goal: I want to show the IRR of 2 proposed modifications of a government program for the retirees who had middle incomes of 20 000$ and 50 000$ in their whole life.
So, I have 4 IRR: 2 for the ones with 20 000$, and 2 for the ones with 50 000$. What's tricky is that I don't have exact x-coordinates; instead, I used nominal x-coordinates to build my histogram bins (using .quad() method).
Then, using the FixedTicker class, I got only 2 tickers to show: the ones that sit between the bins describing each revenue category. At this point, I'm doing this hoping that I can change these fixed tickers to some other custom tickers (maybe using a dict?), but I really don't know.
I'm guessing here, so maybe I'm completey wrong with this FixedTicker strategy. Is there actually a way to modify tickers? If not, is there any other way?
I tried to use categories on the x-axis, but the problem was that I don't have pairs like category:value, it's more like category:(value, value).
Here is my code:
from bokeh.io import show, output_notebook
from bokeh.plotting import figure
from bokeh.models import FixedTicker
output_notebook()
irr_fed = [4.24, 3.04]
irr_prov = [2.59, 2.83]
plot = figure(title="Internal Rates of Return: Federal vs. Provincial",
y_range=(0,5), x_range=(0,12))
plot.quad(top=[irr_fed[0], irr_prov[0], irr_fed[1], irr_prov[1]], bottom=0,
left=[1,3.5,7,9.5], right=[2.5,5,8.5,11])
plot.xaxis[0].ticker=FixedTicker(ticks=[3, 9])
show(plot)
I'd show the plot I get here, but I can't publish images yet, since I'm new here and I don't have enough reputation. If you want to see it, the code works fine in Notebook.
See Question&Answers more detail:
os