Best Python code snippet using autotest_python
graphing_utils.py
Source: graphing_utils.py
...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)...
Check out the latest blogs from LambdaTest on this topic:
Recently, I was going through some of the design patterns in Java by reading the book Head First Design Patterns by Eric Freeman, Elisabeth Robson, Bert Bates, and Kathy Sierra.
The automation backend architecture of Appium has undergone significant development along with the release of numerous new capabilities. With the advent of Appium, test engineers can cover mobile apps, desktop apps, Flutter apps, and more.
As everyone knows, the mobile industry has taken over the world and is the fastest emerging industry in terms of technology and business. It is possible to do all the tasks using a mobile phone, for which earlier we had to use a computer. According to Statista, in 2021, smartphone vendors sold around 1.43 billion smartphones worldwide. The smartphone penetration rate has been continuously rising, reaching 78.05 percent in 2020. By 2025, it is expected that almost 87 percent of all mobile users in the United States will own a smartphone.
We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.
Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!