-
-
Notifications
You must be signed in to change notification settings - Fork 192
Snippets
# finplot uses no background (i.e. white) on even rows and a slightly different color on odd rows.
# Set your own before creating the plot.
fplt.background = '#ff0' # yellow
fplt.odd_plot_background = '#f0f' # purple
fplt.plot(df.Close)
fplt.show()
finplot requires time-ordered time series - otherwise you'll get a crosshair and an X-axis showing the millisecond epoch instead of the actual time. See my comment here and issue 50 for more info.
It is also imperative that you either put your datetimes in your index, or in the first column. If your
datetime is in the first column, you normally want to have a zero-based range index,
df.reset_index(drop=True)
, before plotting.
# By default finplot shows all or a subset of your time series at startup. To store/restore zoom position:
fplt.autoviewrestore()
fplt.show() # will load zoom when showing, and save zoom when closing
# Pandas normally reads datetimes in UTC time zone.
# finplot by default use the local time zone of your computer (for crosshair and X-axis)
from dateutil.tz import gettz
fplt.display_timezone = gettz('Asia/Jakarta')
# ... or in UTC = "display same as timezone-unaware data"
import datetime
finplot.display_timezone = datetime.timezone.utc
To offset your scatter markers (say 0.2 time intervals to the left), see my comment here.
See issue 27, and possibly (rarely a problem) issue 4.
# finplot assumes all your axes are in the same time span. To decouple the zoom/pan link, use:
ax2.decouple()
Use fplt.set_x_pos(xmin, xmax, ax)
. See
examples/animate.py.
For placing ellipses, see issue 57. For drawing lines, see examples/line.py. (Interactively use Ctrl+drag for lines and Ctrl+mbutton-drag for ellipses.)
fplt.candlestick_ochl(df2[['Open','Close','High','Low']], ax=ax.overlay(scale=1.0, yaxis='linear'))
The scale
parameter means it goes all the way to the top of the axis (volume normally stays at the bottom).
The yaxis
parameter can be one of False
(hidden which is default), 'linear'
or 'log'
.
See issue 52 for more info.
finplot is made for plotting time series. To plot something different use ax.disable_x_index()
. See second
axis of examples/overlay-correlate.py.
S&P500 example shows how to set crosshair texts and update legend text+color as a result of mouse hover.
To use your own labels on the X-axis see comment on issue 50.
If you want to roll your own Y-axis, inherit fplt.YAxisItem
.
See examples/line.py. To keep screenshot in RAM see issue 28.
For creating multiple screenshots see issue 71.
See issue 56. Changing the default window size can be
achieved by setting fplt.winw = 900; fplt.winh = 500;
before creating your plot.
See issue 55.
See issue 41. To show grid and further adapt axes, etc:
ax.set_visible(crosshair=False, xaxis=False, yaxis=True, xgrid=True, ygrid=True)
See issue 131.
fplt.play_sound('bot-happy.wav') # Ooh! Watch me - I just made a profit!
Esc
, Home
, End
, g
, Left arrow
, Right arrow
. Ctrl+drag
.
Plot valign on mouse hover, update an orderbook, etc.
- Finance Plot
- Examples
-
Snippets
- Background color
- Unordered time series
- Restore the zoom at startup
- Time zone
- Scatter plot with X-offset
- Align X-axes
- Disable zoom/pan sync between axes
- Move viewport along X-axis (and autozoom)
- Place Region of Interest (ROI) markers
- More than one Y-axis in same viewbox
- Plot non-timeseries
- Custom crosshair and legend
- Custom axes ticks
- Saving screenshot
- Scaling plot heights
- Threading
- Titles on axes
- Fixing auto-zoom on realtime updates
- Playing sound
- Keys
- Missing snippets
- Coffee