I'm new to plotly/plotly express and i'm having a really hard time finding any working example other than the documentation examples for the library (which are really basic and standard).
I have, let's say a scatter plot, in plotly express:
fig = px.scatter(any_random_data)
And i want to add to that plot an image in a fixed (x,y) position, but i don't know (and can't find!) if there is any kind of method for that.
I've seen there is an add_trace() method to add traces to the plot (i guess), is there any similar function for adding images? (Like add_image() or something)
Altair offers lovely feature to facet charts using facet method. For example, following dataset visualizes nicely:
print(df[['Year', 'Profile', 'Saison', 'Pos']].to_csv())
,Year,Profile,Saison,Pos
0,2017,6.0,Sommer,VL
1,2017,6.0,Winter,VL
13,2017,6.0,Winter,HL
12,2017,6.0,Sommer,HL
18,2017,6.0,Sommer,HR
6,2017,6.0,Sommer,VR
7,2017,6.0,Winter,VR
19,2017,6.0,Winter,HR
14,2018,5.5,Winter,HL
8,2018,5.5,Winter,VR
15,2018,5.5,Sommer,HL
20,2018,4.3,Winter,HR
21,2018,5.0,Sommer,HR
3,2018,5.5,Sommer,VL
2,2018,6.2,Winter,VL
9,2018,4.5,Sommer,VR
17,2019,4.5,Sommer,HL
11,2019,4.2,Sommer,VR
22,2019,3.5,Winter,HR
10,2019,5.28,Winter,VR
5,2019,4.6,Sommer,VL
4,2019,4.9,Winter,VL
16,2019,4.0,Winter,HL
23,2019,4.5,Sommer,HR
with the following command:
alt.Chart(df).mark_bar().encode(x='Year:O', y='Profile:Q').facet(row='Saison:N', column='Pos:N')
But, as you can seem I have still a lot of place horizontally and would like to use it by rearranging Winter plot right next to the Summer plot:
I understand that I already used column grid to facet over attribute Pos, but visually for me Winter and Sommer plots are two separate plots (just like here), which I'd like to place side by side.
I tried to create two different charts in the same cell and using html emit them side by side, but in Jupyter environment there is a limitation on just one Altair/Vega plot per cell.
Is there any method I can use to arrange these charts horizontally?
In Altair, there is no good way to do this, because faceted charts cannot be nested according to the Vega-Lite schema. However, the Vega-Lite renderer actually does handle this in some cases, despite it technically being disallowed by the schema.
So you can hack it by doing something like this:
chart = alt.Chart(df).mark_bar().encode(
x='Year:O',
y='Profile:Q'
).facet('Saison:N')
spec = alt.FacetChart(
data=df,
spec=chart,
facet=alt.Facet('Pos:N')
).to_json(validate=False)
print(spec)
The resulting spec can be pasted by hand into http://vega.github.io/editor to reveal this (vega editor link):
You'll even notice that the vega editor flags parts of the spec as invalid. This is admittedly not the most satisfying answer, but it sort of works.
Hopefully in the future the Vega-Lite schema will add actual support for nested facets, so they can be used more directly from Altair.
EDIT: For some reason I've been downvoted twice for posting this question (it hurts ppl) so I've rejigged it.
How do you combine multiple heatmaps in a stacked way with same color scale like to following image?
Additionally, does anyone know how to create the Augmented suffix tree?
Background:
I've worked through the python jupyter notebooks at the following link on how to create the heatmaps of (any) daily consumption profiles using seaborn
http://www.datadrivenbuilding.org/
...however there's a realllllllly cool combination graphic I'd love to be able to reproduce.
That image is an edited version of an image from this paper:
C. Miller, Z. Nagy, A. Schlueter, Automated daily pattern filtering of
measured building performance data, Automation in Construction 49,
Part A (2015) 1–17. doi:10.1016/j.autcon.2014.09.004. URL
http://www.sciencedirect.com/science/article/pii/S0926580514002015
They came up with the visualisation techniques themselves and describe them there. It looks like C. Miller is the one who wrote the notebook that you already found that shows how to draw the stacked heatmaps.
The augmented suffix tree is a type of visualization called a Sankey Diagram. You can plot these very beautifully using Plotly for example, or pySankey if you want to use matplotlib.
I am unsure whether this functionality is possible through Plotly or if it is achievable with other plotting packages so I am open to different solutions.
I am trying to plot two violin plots in a single figure where one violin is oriented horizontally while the other is vertical. I would like to specify the point at which they intersect (i.e the primary axis of each). Ideally each would be transparent and interactive.
Somewhat poor illustration of what I need
Thank you for any proposed solutions!
There are multiple Python libraries doing Violin Plots. Plotly is among them, check its manual.
Besides, Seaborn is really good at this:
It is a Python visualization library based on Matplotlib. The code snipped for the above example can be found in Seaborn's gallery.
for a while I've been trying to come up with a good way to graphically represent a data series along with its estimated error.
Recently I saw some graphs where the data was plotted as a line, with a background 'ribbon' filling the area between the lines plotting data +/- sigma.
Is there a name for this type of graph, and is there any python toolkit which has the capability to make such plots?
A simple way to fake it with matplotlib would also be useful - right now I'm just plotting three lines, but I don't know how to fill the area between them.
I would use the fill_between method. Look at the Our Favorite Recipes section of the manual for matplotlib for some good examples. They have one that looks like this:
and another that looks like this: