FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 392c2617 authored by M.D. Driver's avatar M.D. Driver
Browse files

created script for plotting the information from the polynomial analysis for...

created script for plotting the information from the polynomial analysis for which order fitting is most suitable to use.
parent 87095a08
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script for plotting the polynomial data analysis information as bar charts.
@author: mark
"""
import logging
import numpy as np
import matplotlib.pyplot as plt
import resultsanalysis.resultsoutput.plottinginput as plottinginput
logging.basicConfig()
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.WARN)
COLOUR_LIST = ["r", "b", "g", "c", "m", "y"]
def create_bar_plot_write_to_file(input_data, filename_stem, **kwargs):
"""This creates the bar plot and saves it to file.
"""
bar_plot, bar_plot_axis = create_bar_plot(input_data, **kwargs)
fileformat = kwargs.get("fileformat", "eps")
output_filename = filename_stem + fileformat
plt.savefig(output_filename, format=fileformat)
plt.close(bar_plot)
def create_bar_plot(input_data, **kwargs):
"""This creates the bar plot.
"""
bar_plot, bar_plot_axis = create_plot_with_axis(kwargs.get("figsize",plottinginput.FIGURE_SIZES['vertical bar chart']))
index = np.arange(len(input_data[0]))
n_values = input_data[1]
for i in range(len(n_values)):
if i == 0:
bar_plot_axis.bar(index, n_values[i], color=COLOUR_LIST[i])
else:
bottom = np.zeros(len(index))
for j in range(i-1):
bottom += np.array(n_values[j])
bar_plot_axis.bar(index, n_values[i], bottom=bottom, color=COLOUR_LIST[i])
add_labels_to_plot(bar_plot_axis, index, input_data[0])
return bar_plot, bar_plot_axis
def add_labels_to_plot(bar_plot_axis, index, order_tuple):
"""This adds the labels to the given axis.
"""
bar_plot_axis.ylabel("N")
bar_plot_axis.xlabel("polynomial order")
bar_plot_axis.xticks(index, order_tuple)
def create_plot_with_axis(figsize):
"""This creates the plot and axis.
"""
return plottinginput.create_plot_with_axis(figsize)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment