Closed EKukstas closed 3 years ago
just a minor adjustment on the last line:
import matplotlib.pyplot as plt
from brokenaxes import brokenaxes
import numpy as np
fig = plt.figure(figsize=(5, 2))
bax = brokenaxes(xlims=((0, .1), (.4, .7)), hspace=.05)
x = np.linspace(0, 1, 100)
bax.plot(x, np.sin(10 * x), label='sin')
bax.plot(x, np.cos(10 * x), label='cos')
bax.legend(loc=3)
bax.set_xlabel('time')
bax.set_ylabel('value')
bax.big_ax.text(0.5, 0.8, '0', rotation=90, color='C3', fontsize=12)
well... that sort of works. I think it's using [0,1], [0,1] as the coordinate space. I'll see if I can fix that
First - thank you for coding and sharing brokenaxes
!!!
well... that sort of works. I think it's using [0,1], [0,1] as the coordinate space. I'll see if I can fix that
I'm placing text labels and would like to use the actual coordinate values ( as I used to ). At the moment it is an iterative guessing approach across [0,1] range which makes it harder to generalise ( for me ). Any progress on your comment above?
Hi @Thomas-Moore-Creative No problem, it's fun to see all the cool uses!
This appears to be working as you want for me:
import matplotlib.pyplot as plt
from brokenaxes import brokenaxes
import numpy as np
fig = plt.figure(figsize=(5, 2))
bax = brokenaxes(xlims=((0, .01), (.04, .07)), hspace=.05)
x = np.linspace(0, .1, 100)
bax.plot(x, np.sin(100 * x), label='sin')
bax.plot(x, np.cos(100 * x), label='cos')
bax.legend(loc=3)
bax.set_xlabel('time')
bax.set_ylabel('value')
bax.text(0.045, 0.5, '0', fontsize=12)
this would not work if the underlying axes were [0,1],[0,1].
Note that I am using bax.text, not bax.big_ax.text as I did in the example above
I want to annotate my plots with strings but both 'text' and 'annotate' ignore the axis limits set by brokenaxes. Using one of the examples:
I get the following:
I feel like it's a simple enough fix but can't figure out what I need to change in order to suppress the second annotation being plotted. Can anyone point me in the right direction?