Bokeh: Making charts "interact" or link with one another - python

To better explain what I mean in the title...
Let's say I have line plot graph that shows adjusted close for a stock for 01.01.2016 until now, and then i have another bokeh chart that displays histogram of volumes for the exact same stock for exact same time period.
What I want is:
Zoom in on a particular time period in adj close graph
Have volume histogram graph adjust to the same time period.
and vice versa...

It seem to me that this example do something very similar to what you are you asking for.
The bit that link one chart to another is in figure definition, i.e in:
p2 = figure(x_range=p.x_range)
x_range=p.x_range link the x range of the current figure with x range of figure p.

Related

Is there a way to make a python plot with changing axis titles if zooming in or out

I'm not looking for an in-depth solution to this problem more so just a pointer in the right direction. I am logging data from 2019 until 2022, it is infrequent sometimes there is data once a day or maybe no data for some months. I would like to be able to view averages for different time scales on the same graph using something like a zoom button. If I'm zoomed out to the max I would like 4 points of data, each year's average, if I zoom in once it may zoom into 2022 and show me each month's average with 12 data points, zoom in again and the weekly average for maybe 24 weeks etc.
Another point to mention is each data point has 4 values, so my current approach is storing them in a list of dictionaries, which I'm hoping to unroll and access with whatever graphing method I end up using.
I'm not aware of what library could make this possible. Thanks

Full datetimes in x-axis

I am new to programming in general, and I have started with Python. I have a project where i have to create various plots (y-axis: voltage, frequency etc, x-axis: exact datetimes ) from a csv file which contains the meterings of a home smart meter. I try to create a plot between 2 certain datetimes (not from start to end). I have fairly managed to do it but I face some problems in concern of the x-axis. I want to get for example "2020-09-22 09:00:02" but I get for example "9-22 10".
enter image description here

Matplotlib - what is the best way to draw a straight line between the highs and lows of a stock graph?

I have a bunch of data that plots a graph like the black part of the following image (think stock graph). Let's assume this data is all within 1 month. Here, we have 5 high humps, and 5 low humps.
What is the best way to recognize those high and low humps of the black line, and put another diagonal line over them (green in this case) so that it shows a narrowing?? I'm not asking for an answer in code, just if there is a quick option, because when I look through the examples on matplotlib, I don't see anything that does this.
Or would I need some other library or something for this???
Why don't take a look at mlpfinance, although diagonal line (green) you might have to write a custom plot, similar line can be achieved drawing long duration simple moving average.
Edit:
plotting cummax()

How to draw smooth trend line with matplotlib in Python with Date in X axis?

I have to generate analysis of flight reports. In the chart I'm trying to draw, each point is corresponding to one flight with the Date in X-axis. So, It is possible to have several points for the same X.
Each point represent the aircraft speed at a specific moment in the flight. The pilot did good if the value (IAS in knots) is in the range 80-95. So, I want to show if the pilot is getting better by a running median on 8 values. But, sometime there are multiple flights on the same day so it creates "vertical lines" in the trendline.
I'm using Python on Databricks.
There is my dataset:
And there is the plot:
What is the best way to draw a smooth trend line dealing with Date as X-axis and the multiple points on same X ?
Thanks

Plotting 2-D time-series data on one y-axis with two properties

I'm trying to plot EEG (electroencephalography) data (an array of nElectrodes by nTimepoints) in python. I want to create a plot representing each electrode on the y-axis and each time point on the x-axis, but I also want the amplitude response to be represented on the y-axis. Here's an example of what I want the graph to look like (sorry for the rubbish xkcd powerpointedness of the graph):
http://i.stack.imgur.com/9LPqF.png
I'm having difficulty working out how to do this, particularly getting my head around giving each 'electrode' the ability to overlap with other electrodes (making artefacts much easier to spot).
I would really appreciate any help, so thanks in advance!
Darren
So upon looking back at the suggestion from #sebix, the following link has a small section of plotting script at the end which seems to work well for what I want. Here's the link below:
http://matplotlib.org/1.2.1/examples/pylab_examples/mri_with_eeg.html
I've never used offsets or anything before so this is new territory for me! Thanks for the comments.

Categories

Resources