# -*- coding: utf-8 -*- """ Created on Mon May 30 20:57:26 2016 @author: Ben """ import clearplot.plot_functions as pf import numpy as np import matplotlib.mlab as mlab #Verification that image background contour plot works delta = 0.025 x = np.arange(-1.5, 1.5 + delta/100, delta) y = np.arange(-1.5, 1.5 + delta/100, delta) xa, ya = np.meshgrid(x, y) r = (xa + 1.5)**2.0 + (ya + 1.5)**2.0 z1 = mlab.bivariate_normal(xa, ya, 1.0, 1.0, 0.0, 0.0) z2 = mlab.bivariate_normal(xa, ya, 1.5, 0.5, 1, 1) za = 10.0 * (z2 - z1) pf.plot_contours('contour_plot-background_image', xa, ya, za, \ ['\tau_1', 'kg'], ['\tau_2', 'kg'], \ x_tick = 0.5, y_tick = 0.5, x_lim = [-1.5, 1.5], y_lim = [-1.5, 1.5], \ c_label = ['E', 'kJ'], plot_type = 'image', im_interp = 'bilinear')
@author: Ben """ import clearplot.plot_functions as pf import clearplot.figure as cpfig import clearplot as cp import numpy as np #Verification that the image position is consistent with the contour lines. #(This is best seen with a very coarse image.) Also verify that multiple #contour plots can be placed in a figure window #Generate a coarse data set so that individual image pixels are easily visible. x = np.array([[0,1,2,3], [0,1,2,3], [0,1,2,3], [0,1,2,3]]) y = np.array([[0,0,0,0], [1,1,1,1], [2,2,2,2], [3,3,3,3]]) z = np.array([[0.25, 0.75, 1.0, 0.75], [0.1, 0.65, 0.5, 0.4], [0.6, 0.3, 0.0, 0.2], [0.7, 0.9, 0.4, 0.6]]) #Create figure window fig_size = np.array([1200, 400]) / cp.params.dpmm fig = cpfig.Figure(size = fig_size) #Add plots to figure window [fig, ax, bg, cl] = pf.plot_contours('', x, y, z, plot_type = 'filled', \ fig = fig, ax_pos = [35, 30], c_label = ['z', 'mm'], x_tick = 1, y_tick = 1) ax.add_title('Filled') [fig, ax, bg, cl] = pf.plot_contours('', x, y, z, plot_type = 'image', \ fig = fig, ax_pos = [155, 30], c_label = ['z', 'mm'], \ x_tick = 1, y_tick = 1, x_lim = [0,3], y_lim = [0,3]) ax.add_title('Image') [fig, ax, bg, cl] = pf.plot_contours('', x, y, z, plot_type = 'lines', \ fig = fig, ax_pos = [275, 30], c_label = ['z', 'mm'], x_tick = 1, y_tick = 1) ax.add_title('Lines Only') #Save result fig.save('contour_plot-background_position')
# -*- coding: utf-8 -*- """ Created on Sat Apr 18 17:36:03 2015 @author: Ben """ import clearplot.plot_functions as pf import numpy as np import matplotlib.mlab as mlab delta = 0.025 x1d = np.arange(-1.5, 1.5 + delta/100, delta) y1d = np.arange(-1.5, 1.5 + delta/100, delta) x, y = np.meshgrid(x1d, y1d) z1 = mlab.bivariate_normal(x, y, 1.0, 1.0, 0.0, 0.0) z2 = mlab.bivariate_normal(x, y, 1.5, 0.5, 1, 1) z = 10.0 * (z2 - z1) pf.plot_contours('contour_plot-filled.png', x, y, z, ['\tau_1', 'kg'], \ ['\tau_2', 'kg'], x_tick = 0.5, y_tick = 0.5, c_label = ['E', 'kJ']);