Plotting with Facebook's "fbprophet" Python API, how can I hide "capacity"? - python
I'm currently playing around with the fbprophet Python API that Facebook just released for time series forecasting.
My forecast dataframe looks like this:
forecast.head()
ds,cap,t,trend,seasonal_lower,seasonal_upper,trend_lower,trend_upper,yhat_lower,yhat_upper,yearly,yearly_lower,yearly_upper,seasonal,yhat
2008-08-01,21064.0,0.0,13534.8985798,295.074941086,3627.77638435,12515.7266808,14582.8551068,12328.7743552,18619.6705558,2330.03631841,611.380084432,3802.86997467,2014.50868144,15549.4072612
2008-09-01,21600.0,0.0101839684625,13431.7394718,1438.43275222,4947.87832578,12450.622301,14428.4657678,13422.5289632,19595.7519179,2545.44444698,1140.23960946,3979.38497822,3089.74759767,16521.4870695
2008-10-01,21966.0,0.0200394218134,13331.908077,1834.90809248,4653.4289911,12382.4033864,14294.8653737,13411.0205974,19818.8904872,2886.28927049,1512.9361508,4269.31963345,3230.24309437,16562.1511714
2008-11-01,14387.0,0.030223390276,13228.7489691,-3351.95070458,-496.310787437,12312.4002068,14162.0170017,8077.85318805,14293.8736792,-2139.69062288,-3514.21626125,-943.144422123,-1895.13014899,11333.6188201
2008-12-01,12377.0,0.0400788436268,13126.5256588,-5241.07039645,-2399.13703352,12246.8937196,14031.1107877,6254.36024438,12626.4645414,-4278.57816444,-5379.58985709,-3176.14935573,-3734.27501375,9392.25064509
This is fine for plotting the simple plot with capacity as a dotted line.
My problem, however, is that if I plot the components
model.plot_components(forecast).show()
see my components_plot
I still get the dotted line of capacity on top of the annual trend line (which is not relevant at all).
My work-around is to delete the column "cap" from the dataframe before plotting.
del forecast['cap']
Isn't there a less destructive way to proceed to plot the trends without the capacity?
Related
How to plot geographical data with Plotly
I know my question might sound a bit too general but I actually just need some guidance to start learning geographical plotting with Plotly package iin python. I'm following guides on the internet but I never really manage to replicate the method with data I find on the internet. The simple case I'm trying to plot is the following: I have a Geopandas dataframe gdf with coordinates of point samples and a value, all measured in a particular European state (Netherlands in my case). I found on the internet a shape of the state in json (link to json) What I am trying to do is: Plotting a blank choropleth map of the Netherlands, so that it would set the correct position for points of the dataframe On top of the previous layer, I want to plot the points of my gdf I'm not asking for code so I won't be posting the gdf. What I really want to understand is Is this (px.choropleth overlayed with px.scatter_geo) the best way to plot points on a conventional geographical area? What are the features that need to be present on my gdf in order to make this work? For now it has a 'geometry' column and a 'value' column. Also feel free to post any additional resource that might prove helpful to start learning this topic (as long they explain every step and don't assume familiarity with geodata structure).
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
Plotting hierarchical clustering dendrograms for large data sets
I have a huge data set of time series data. In order to visualise the clustering in python, I want to plot time series graphs along with the dendrogram as shown below. I tried to do it by using subgrid2plot() function in python by creating two subplots side by side. I filled first one with series graphs and second one with dendrograms. But once number of time series increased, it became blur. Can someone suggest a nice way to plot this type of dendrogram? I have around 50,000 time series to cluster and visualise.
Convert data into JSON with json module of python and then use D3.js for graph ploting. Check the Gallery from here where you can find dendrogram and time series graph
Timeseries streaming in bokeh
I want to plot a live time series in bokeh. I want to plot only the new data points at each update. How can I do this ? There is an example on the bokeh website for animated plots but it involves redrawing the whole picture every time. Also I am looking for a simple example where I can do a live plot of a time series point by point.
As of Bokeh 0.11.1 there is now a streaming interface to column data sources in Bokeh server apps. You can see and easily run an example here: https://github.com/bokeh/bokeh/tree/master/examples/app/ohlc That example shows a live updating OHLC chart with MACD indicator (based on synthetic tick data) that only updates the plot with the most recent data points on every update. Basically, using the streaming interface consists of two parts. First create a new dict with same "shape" as your column data source: new_data = dict( time=[t], open=[open], high=[high], low=[low], close=[close], average=[average], color=[color], ) Then pass this to the .stream method, with an optional rollover argument that specifies how big of a buffer to keep in the browser (earlier data starts to get dropped off): source.stream(new_data, 300) Then, just the small amount of data in new_data willbe sent to the plot, not everything.
How to draw a graph that can indicate the values when the mouse moves to some part of the graph in python and put it on the web page?
I'm writing a web interface for a database of genes values of some experiments with CGI in Python and I want to draw a graph for the data queried. I'm using matplotlib.pyplot, draw a graph, save it, and perform it on the web page. But usually there are many experiments queried hence there are a lot of values. Sometimes I want to know which experiment does one value belong to because it's a big value, whereas it's hard to identify because the picture is small in size. The names of the experiments are long strings so that it will mess the x axis if I put all the experiment names on the x axis. So I wonder if there is a way to draw a graph that can interact with users, i.e. if I point my mouse to some part on the graph, there would be one small window appears and tells me the exact value and what is the experiment name here. And the most important is, I can use this function when I put the graph on the web page. Thank you.
What you want is basically D3.js rendering of your plots. As far as I know, there are currently three great ways of achieving this, all under rapid development: MPLD3 for creating graphs with Matplotlib and serving them as interactive web graphics (see examples in Jake's blog post). Plotly where you can either generate the plots directly via Plotly or from Matplotlib figures (e.g. using matplotlylib) and have them served by Plotly. Bokeh if you do not mind moving away from Matplotlib.