How to use _get_adjusted_bar method in autotest

Best Python code snippet using autotest_python

graphing_utils.py

Source:graphing_utils.py Github

copy

Full Screen

...231 # markers in the legend.232 for line in legend.get_lines():233 line.set_marker(_LEGEND_MARKER_TYPE)234 return (figure, area_data)235def _get_adjusted_bar(x, bar_width, series_index, num_plots):236 """\237 Adjust the list 'x' to take the multiple series into account. Each series238 should be shifted such that the middle series lies at the appropriate x-axis239 tick with the other bars around it. For example, if we had four series240 (i.e. four bars per x value), we want to shift the left edges of the bars as241 such:242 Bar 1: -2 * width243 Bar 2: -width244 Bar 3: none245 Bar 4: width246 """247 adjust = (-0.5 * num_plots - 1 + series_index) * bar_width248 return [x_val + adjust for x_val in x]249# TODO(showard): merge much of this function with _create_line by extracting and250# parameterizing methods251def _create_bar(plots, labels, plot_info):252 """\253 Given all the data for the metrics, create a line plot.254 plots: list of dicts containing the plot data.255 x: list of x-values for the plot256 y: list of corresponding y-values257 errors: errors for each data point, or None if no error information258 available259 label: plot title260 labels: list of x-tick labels261 plot_info: a MetricsPlot262 """263 area_data = []264 bars = []265 figure, height = _create_figure(_SINGLE_PLOT_HEIGHT)266 # Set up the plot267 subplot = figure.add_subplot(1, 1, 1)268 subplot.set_xticks(range(0, len(labels)))269 subplot.set_xlim(-1, len(labels))270 subplot.set_xticklabels(labels, rotation=90, size=_BAR_XTICK_LABELS_SIZE)271 # draw a bold line at y=0, making it easier to tell if bars are dipping272 # below the axis or not.273 subplot.axhline(linewidth=2, color='black')274 # width here is the width for each bar in the plot. Matplotlib default is275 # 0.8.276 width = 0.8 / len(plots)277 # Plot the data278 for plot_index, (plot, color) in enumerate(zip(plots, _colors(len(plots)))):279 # Invert the y-axis if needed280 if plot['label'] in plot_info.inverted_series:281 plot['y'] = [-y for y in plot['y']]282 adjusted_x = _get_adjusted_bar(plot['x'], width, plot_index + 1,283 len(plots))284 bar_data = subplot.bar(adjusted_x, plot['y'],285 width=width, yerr=plot['errors'],286 facecolor=color,287 label=plot['label'])288 bars.append(bar_data[0])289 # Construct the information for the drilldowns.290 # See comment in _create_line for why we need a separate loop to do this.291 for plot_index, plot in enumerate(plots):292 adjusted_x = _get_adjusted_bar(plot['x'], width, plot_index + 1,293 len(plots))294 # Let matplotlib plot the data, so that we can get the data-to-image295 # coordinate transforms296 line = subplot.plot(adjusted_x, plot['y'], linestyle='None')[0]297 label = plot['label']298 upper_left_coords = line.get_transform().transform(zip(adjusted_x,299 plot['y']))300 bottom_right_coords = line.get_transform().transform(301 [(x + width, 0) for x in adjusted_x])302 # Get the drilldown query303 drill = plot_info.query_dict['__' + label + '__']304 # Set the title attributes305 x_labels = [labels[x] for x in plot['x']]306 titles = ['%s - %s: %f' % (plot['label'], label, y)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful