I was wondering if it is possible to set an error bar series to a reference. What I would like to do is reference cells with the error values already calculated. and then have it displayed on top of the bar graphs.
I found a similar question where they have seemed to do a version of what I am trying, but when I edit their example I get an error. Any advice would be much appreciated. Thank you for your time.
Example of what I want the graph and error bars to look like Error:
TypeError: expected class 'openpyxl.chart.error_bar.ErrorBars'
similar Question openpyxl chart error bar styles
My Current Code
chart1 = BarChart()
chart1.type = "col"
chart1.height = 10
chart1.width = col + 7
chart1.title = name
data = Reference(ws, min_col=4, min_row=23, max_col=17)
cats = Reference(ws, min_col=4, min_row=29, max_col = 17)
eBars = Reference(ws, min_col=4, min_row=26, max_col=17)
s= Series(data)
series = SeriesFactory(data, title="y direction error")
series.errBars = eBars
chart1.append(s)
chart1.append(series)
chart1.legend = None
chart1.set_categories(cats)
chart1.x_axis.tickLblPos = "low"
#chart1.x_axis.tickLblSkip = 0
chart1.shape = 10
ws.add_chart(chart1, "C3")
I see your point, replace
numLit
withnumRef
:Your
eBars
is of TypeReference
but you need Typeopenpyxl.chart.error_bar.ErrorBars
.You need at least the following Parameters:
Follow
def list2errorbars(...
in the linked similar Question.