Is there any built in function in pandas to subtract various columns to manipulate a stacked bar chart? - pandas

I hope I do not brake too much rules (this is my first post).
First Things first: I'm sorry, but I cannot post an image of my plots or Code right now. So I created a pretty image in paint. On the left side you see what I want to create, on the right side you see what I create right now.
Example
I was able to make a barchart as shown on the left side with lots of detours. Since I have to analyse lots of data in similar charts I want to use the built in plot function of Pandas.
What I need: stacked bar chart, where the values are not summed up (like shown in the right image) but the difference of the values are summed up (like shown in the left image). So if s1 = 2 and s2 = 6 and i just do some stuff like groupby().unstack().plot(kind='bar', stacked=True) I got stacked bars which end at y=2 for s1 and y=8 for s2 (like shown in the right diagram).
How can I modify my code so that I will get y=2 for s1 and y=6 for s2?.
I thought about diff(), but the result was definetly not like expected.
I hope my question is clear.
Thanks for your adviced and best regards
Arnfried

Related

How to add descriptions on selected data series to an area plot in mathplotlib

I created a graph that looks alright to me with the following line of code:
df_wide.plot.area(xticks=df_wide.index, legend=False, xlabel= 'Week', ylabel='Percent', title='Percentage of Letters')
However I would like to add the name of selected (or all) dataseries to the right side of the Graph, so that it attaches little lines to the right side and the column name appears next to it, I attach a picture with my current output and how I want it to look (not exactly well edited, but I am sure you get the idea)...
Maybe somebody can helb me :) Thank you!

how to align chart + html.table in a Plotly Dash app?

I'm trying to reproduce a layout where the table and the chart should be aligned as in the image below:
The main idea is to work for 1 to N values, always aligned to each other.
I tried to create a "fake" graph inside the table but as you can see in the image below it doesn't work exactly as expected
So I would like to know what's the best way to:
1- calculate and set the size needed for each bar in the graph
2 - set it dynamically based on how many entries the data has
3 - Don't forget please, ALWAYS ALIGNED
IF needed I can share the code of the table or of the layout graph + table I'm using;
Thank you in advance.
Regards,

Conditional label for selected stack bar chart in facet ggplots 2

I am looking for a help to display labels for a selected stack bar, e.g. "Net impacts" stack, in the facet_wrap stack figure below. I tried to use geom_text(aes(label=ifelse())) but it does not work.
Any suggestion would be grateful. Thanks in advance.
Stack-bars chart Figure
Update: So, instead of displaying the labels for a selected stack-bar, I've just come up with the combination of stack-bar and point chart figure Stack-bars and Points chart. I am satisfied with the yellow points presenting sum of stack-bars at each column, though it would be much better if these values can be showed on each bar. Any suggestion please?!
In addition, is it possible to show scientific number as labels for the points/stack-bars?

Connect Xaxis of a chart to another one

I have an application made of a "main" chart with stock quotes plotted in it and a "subordinated" one with some indicators; the two charts are dinamically feeded with data so they are ever moving and re-sizing their own YAxis accordingly. The following snapshot gives a better idea:
What I would like to do is to make the below chart XAxis exactly the same of the first one, so that it is possible to follow the evolution of the two indicators together.
Right now I'm doing the following work around:
With ChartBelow.ChartAreas(0)
.AxisX.Minimum = ChartAbove.ChartAreas(0).AxisX.Minimum
.AxisX.Maximum = ChartAbove.ChartAreas(0).AxisX.Maximum
End With
However this doesn't work well since the digits of the YAxis on the main chart are not always the same of the second one (as in the example above where it's 6-digits against 3-only).
Is there any way to aligne the two y-axes or make the X-Axis shared between the two charts?
Yes, as well as setting the Min/Max values, also set the interval and label interval values of the Axis.
ChartAbove.ChartAreas(0).XAxis.Interval
ChartAbove.ChartAreas(0).XAxis.LabelStyle.Interval

Highcharts: Polar columns datalabels inside position

I'm trying to get values (datalabels) of a columns polar chart INSIDE the actual column, and not on top of it. I've set inside: true property but it does not seem to have any effect, although it works pretty nicely while using a regular stacked columns chart for example.
Here is the fiddle showing the issue: http://jsfiddle.net/deurk/BeVyt/2/
Ideally, I'd like to have the datalabels in their "shares" if there is enough space, with white color. Does anyone have a workaround for this?
Thanks!
Indeed it looks like a bug, so I've reported it here https://github.com/highslide-software/highcharts.com/issues/1688