How to use 'bar chart in python' in Python

Every line of 'bar chart in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
281def generate_bar_chart(chart_data, bottoms=None, bar_width=0.4, labels=[], orientation='vertical'):
282 """
283 Creates a bar chart for revenue using chart_data.
284 """
285 fig, ax = plt.subplots(figsize=(12, 6))
286
287 # Get the revenue data from the ValOp objects.
288 indices = np.arange(len(chart_data))
289
290 # Plot.
291 with sb.axes_style('whitegrid'):
292 if bottoms is None:
293 if orientation == 'horizontal':
294 ax.barh(indices, chart_data, height=bar_width, color=PALETTE)
295 plt.yticks(indices, labels, rotation=0)
296 ax.set_xticklabels(['{:,}'.format(int(x)) for x in ax.get_xticks().tolist()]) # Comma separator for y-axis tick labels.
297 else:
298 ax.bar(indices, chart_data, width=bar_width, color=PALETTE)
299 plt.xticks(indices, labels, rotation=0)
300 ax.set_yticklabels(['{:,}'.format(int(x)) for x in ax.get_yticks().tolist()]) # Comma separator for y-axis tick labels.
301 else:
302 if orientation == 'horizontal':
303 ax.barh(indices, chart_data, left=bottoms, height=bar_width, color=PALETTE)
304 plt.yticks(indices, labels, rotation=0)
305 ax.set_xticklabels(['{:,}'.format(int(x)) for x in ax.get_xticks().tolist()]) # Comma separator for y-axis tick labels.
306 # ax.set_xlim(0, max(chart_data))
307 else:
308 ax.bar(indices, chart_data, bottom=bottoms, width=bar_width, color=PALETTE)
309 plt.xticks(indices, labels, rotation=0)
310 ax.set_yticklabels(['{:,}'.format(int(x)) for x in ax.get_yticks().tolist()]) # Comma separator for y-axis tick labels.
311 # ax.set_ylim(0, max(chart_data))
312
313 # sb.despine(offset=10, trim=True)
314
315 return fig, ax
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets