I'm plotting a curve from some data points:
points = [[0.0, 0.0], [1, 3], [3, 5]]
... and I want it to reach, say, y = 10 as x goes to infinity. In other words, the extra "point" to append would be: [float('inf'), 10]
Is there a way to tell matplotlib
to plot the asymptotic behaviour of this last part of the curve?
Matplotlib disregards float('info')
, so I guess there should be another way to do this.
You can't plot a function of infinity because it isn't a number. I think the only way to achieve the effect that you want is with a broken axis and the data point plotted at some arbitrarily large number. An example of how to do the broken plot is available from the official matplotlib site.
The basic idea is to create two subplots with borders cleverly removed so as to look like a single plot then add some fancy diagonal lines to make it look like a conventional "broken" plot. You can plot your infinity data point in its own subplot by substituting a sufficiently large number (to make the curve look right). Then just relabel the tick to infinity (ax.set_xticks([large_number])
ax.set_xticklabels(['\infty']
) assuming ax
is the second plot that only has your infinity point) and you're in business!
I have recently used a modified form of the above example to plot a point "at infinity". I have code that does this but it's full of references to my specific data so it will probably be about as helpful to you as the official example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With