def test_histogram_plot_parse_column(): plat = platform.system() if plat == 'Darwin': plt_name = '../data/test/hist1.eps' else: plt_name = r'..\data\test\hist1.eps' np.random.seed(19680801) x = np.random.normal(15.0, 3.0, 1000) y = np.random.normal(20.0, 3.0, 1000) data = [x, y] labels = ['one', 'two'] one = np.repeat('one', len(x)) two = np.repeat('two', len(x)) x = np.hstack((x, y)) y = np.hstack((one, two)) dictionary = {'data': x, 'type': y} df = pd.DataFrame(dictionary) obj = MatPlotDataFrame(df) obj.histogram_plot_parse_column('data', 'type', labels, x_label='x-axis', y_label='y-axis', shading=[0.9, 0.4], save=True, plot_name=plt_name) assert os.path.isfile(plt_name) if os.path.isfile(plt_name): os.remove(plt_name)
def test_matplot_line_plot_column(): plat = platform.system() if plat == 'Darwin': plt_name = '../data/test/line2.eps' else: plt_name = r'..\data\test\line2.eps' length = 20 x = np.linspace(0, 20, num=20) linear = x squared = x**2.0 # create dataframe dictionary = {'x': x, 'linear': linear, 'squared': squared} df = pd.DataFrame(dictionary) # plot data obj = MatPlotDataFrame(df) x_headers = ['x', 'x'] y_headers = ['linear', 'squared'] obj.line_plot_columns(x_headers, y_headers, y_headers, x_label='x-axis', y_label='y-axis', title='Test', style_name='default', line_colors=['red', 'green'], fill_alpha=0.7, label_pos='upper left', grid=True, save=True, plot_name=plt_name) assert os.path.isfile(plt_name) if os.path.isfile(plt_name): os.remove(plt_name)
def test_matplot_timedate_plot_parse_column(): plat = platform.system() if plat == 'Darwin': plt_name = '../data/test/time1.eps' else: plt_name = r'..\data\test\time.eps' length = 6 dates = pd.date_range(start=pd.to_datetime('2016-09-24'), periods=length, freq='y') x = np.linspace(0, length, num=length) linear = x squared = x**2.0 lin = np.repeat('linear', length) sq = np.repeat('squared', length) # Combine arrays into one x = np.hstack((dates, dates)) y = np.hstack((linear, squared)) power = np.hstack((lin, sq)) # Create dataframe dictionary = {'dates': x, 'y': y, 'power': power} df = pd.DataFrame(dictionary) # Plot data obj = MatPlotDataFrame(df) parsing_header = 'power' column_values = ['linear', 'squared'] obj.timedate_plot_parse_column('dates', 'y', parsing_header, column_values, x_label='x-axis', y_label='y-axis', title='Test', style_name='default', line_colors=['red', 'green'], fill_alpha=0.7, label_pos='upper left', grid=True, save=True, plot_name=plt_name) assert os.path.isfile(plt_name) if os.path.isfile(plt_name): os.remove(plt_name)
def test_matplot_scatter_plot_parse_column(): plat = platform.system() if plat == 'Darwin': plt_name = '../data/test/scatter1.eps' else: plt_name = r'..\data\test\scatter1.eps' length = 20 x = np.linspace(0, 20, num=20) linear = x squared = x**2.0 lin = np.repeat('linear', 20) sq = np.repeat('squared', 20) # Combine arrays into one x = np.hstack((x, x)) y = np.hstack((linear, squared)) power = np.hstack((lin, sq)) # Create dataframe dictionary = {'x': x, 'y': y, 'power': power} df = pd.DataFrame(dictionary) # Plot data obj = MatPlotDataFrame(df) parsing_header = 'power' column_values = ['linear', 'squared'] obj.scatter_plot_parse_column('x', 'y', parsing_header, column_values, x_label='x-axis', y_label='y-axis', title='Test', style_name='default', marker_colors=['red', 'green'], fill_alpha=0.7, marker_style=['o', '^'], label_pos='upper left', grid=True, save=True, plot_name=plt_name) assert os.path.isfile(plt_name) if os.path.isfile(plt_name): os.remove(plt_name)
def test_histogram_plot_columns(): plat = platform.system() if plat == 'Darwin': plt_name = '../data/test/hist2.eps' else: plt_name = r'..\data\test\hist2.eps' np.random.seed(19680801) x = np.random.normal(15.0, 3.0, 1000) y = np.random.normal(20.0, 3.0, 1000) data = [x, y] labels = ['one', 'two'] dictionary = {'x': x, 'y': y} df = pd.DataFrame(dictionary) obj = MatPlotDataFrame(df) obj.histogram_plot_columns(['x', 'y'], labels, x_label='x-axis', y_label='y-axis', shading=[0.9, 0.4], save=True, plot_name=plt_name) assert os.path.isfile(plt_name) if os.path.isfile(plt_name): os.remove(plt_name)
def test_matplot_timedate_plot_parse_column(): plat = platform.system() if plat == 'Darwin': plt_name = '../data/test/line1.eps' else: plt_name = r'..\data\test\line.eps' length = 6 dates = pd.date_range(start=pd.to_datetime('2016-09-24'), periods=length, freq='y') x = np.linspace(0, length, num=length) linear = x squared = x**2.0 dictionary = {'dates': dates, 'squared': squared, 'linear': linear} df = pd.DataFrame(dictionary) # Plot data obj = MatPlotDataFrame(df) time_axis = ['dates', 'dates'] y_axis = ['linear', 'squared'] obj.timedate_plot_columns(time_axis, y_axis, y_axis, x_label='x-axis', y_label='y-axis', title='Test', style_name='default', line_colors=['red', 'green'], fill_alpha=0.7, label_pos='upper left', grid=True, save=True, plot_name=plt_name) assert os.path.isfile(plt_name) if os.path.isfile(plt_name): os.remove(plt_name)