Пример #1
0
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 15:07:09 2015

@author: Ben
"""
import clearplot.plot_functions as pf
import numpy as np

x = np.arange(0,10,0.01)
y = np.sqrt(x)

pf.plot('basic.png', x, y, \
	x_label = ['\phi', '\%'], y_label = ['\psi', 'GPa'], \
    x_lim = ['auto', 16], x_tick = 4);
Пример #2
0
# -*- coding: utf-8 -*-
"""
Created on Mon May 30 20:39:01 2016

@author: Ben
"""

import clearplot.plot_functions as pf

#Verfication that multiple legends can be added to a plot
[fig, ax, curves] = pf.plot('', [0,1], [0,1], ['P'], 'x', 'y', \
    legend = True, legend_loc = 'upper left')
markers = ax.plot_markers([0.25, 0.75], [0.25, 0.75], labels = ['A'], \
    shapes = '+', sizes = 10, edge_widths = 2)
ax.add_legend(curves, loc = 'upper left')
ax.add_legend(markers, loc = 'lower right')
fig.save('multiple_legends')
Пример #3
0
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 15:35:34 2015

@author: Ben
"""
import clearplot
import clearplot.plot_functions as pf
import numpy as np

x = np.arange(0,10,0.01)
y = np.sqrt(x)

pf.plot('math_text_typesetting.png', x, y, \
    x_label = ['\int_0^x \exp\left[\hat{x}\right]\,\mathrm{d}\hat{x}'], \
    y_label = ['\frac{P}{A}', 'GPa'])
    
clearplot.params.use_latex(True)
[fig, ax, curves] = pf.plot('LaTeX_typesetting.png', x, y, \
    x_label = ['\int_0^x \exp\left[\hat{x}\right]\,\mathrm{d}\hat{x}'], \
    y_label = ['\displaystyle \frac{P}{A}', 'GPa'])
Пример #4
0
# -*- coding: utf-8 -*-
"""
Created on Mon May 30 20:40:08 2016

@author: Ben
"""

import clearplot.plot_functions as pf

#Verification that scaling the plot works cprrectly
pf.plot('scaled_plot', [0,1,2], [0,0.1,0.15], \
    x_label = ['x', 'mm'], y_label = ['y', 'mm'], \
    scale_plot = 1.5, font_size = 24)
Пример #5
0
# -*- coding: utf-8 -*-
"""
Created on Mon May 30 20:41:30 2016

@author: Ben
"""

import clearplot.plot_functions as pf
import numpy as np

#Verification that manually picked arrows work properly
xa = np.arange(0, 1.001, 0.001)
ya = np.sqrt(0.0625 - ((xa-0.5)/2.0)**2.0) * 12.0
xa = np.append(xa, np.flipud(xa))
ya = np.append(ya, -np.flipud(ya))
xb = xa * 2.35
yb = ya * 1.45
[fig, ax, curves] = pf.plot('', \
    [xa, xb], [ya, yb])
ax.add_arrowheads_to_curves(pick = 'middle')
fig.save('manually_picked_arrows')
Пример #6
0
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 15:08:47 2015

@author: Ben
"""
import clearplot.plot_functions as pf
import numpy as np

xa = np.arange(0,10,0.01)
ya = np.sqrt(xa)
xb = xa
yb = 3.0 * (xb/10)**3 - 2.0 * (xb/10)**2

[fig, ax, curves] = pf.plot('two_curves-legend.png', [xa, xb], [ya, yb], \
    labels = ['\kappa_y', '\kappa_z'], \
    x_label = ['\zeta_{yz}', 'in'], y_label = ['\kappa', 'lbf'])
Пример #7
0
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 15:04:55 2015

@author: Ben
"""
import clearplot.params
import clearplot.plot_functions as pf
import numpy as np

clearplot.params.axis_arrow_bool = False

x = np.arange(0,10,0.01)
y = np.sqrt(x)

pf.plot('no_axis_arrows.png', x, y, \
    x_label = ['\sf{Volume\;Change}', '\%'], \
    y_label = ['\psi', 'GPa']);
Пример #8
0
# -*- coding: utf-8 -*-
"""
Created on Mon May 30 21:11:27 2016

@author: Ben
"""

import clearplot.plot_functions as pf

#Verification that duplicate legend labels are automatically removed
x19a = [0,1]
x19b = [0,1]
x19c = [0,1]
x19d = [0,1]
x19e = [0,1]
x19f = [0,1]
y19a = [0,0.1]
y19b = [0,0.2]
y19c = [0,0.3]
y19d = [0,0.4]
y19e = [0,0.5]
y19f = [0,0.6]
pf.plot('duplicate_legend_labels', \
    [x19a, x19b, x19c, x19d, x19e, x19f], \
    [y19a, y19b, y19c, y19d, y19e, y19f], \
    curve_colors = [[1,0,0], [0,1,0], [0,1,0], [0,0,1], [0,0,1], [0,0,1]],\
    curve_widths = [1,2,2,3,3,3], \
    curve_styles = ['-', '--', '--', ':', ':', ':'],\
    labels = ['\Omega_1', '\Omega_2', '\Omega_2', \
    '\Omega_3', '\Omega_3', '\Omega_3'], legend = True)
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 15:10:23 2015

@author: Ben
"""
import clearplot.plot_functions as pf
import numpy as np

xa = np.arange(0,10,0.01)
ya = np.sqrt(xa)
xb = xa
yb = np.log(xb + 1.0)

[fig, ax, curves] = pf.plot('', [xa, xb], [ya, yb], \
    labels = ['\Omega_1', '\Omega_2'], legend = False, \
    x_label = ['\omega_{x}'], y_label = ['\Omega'])
ax.label_curves(ndx = [500, 530], angles = [120, -60])
fig.save('two_curves-labels-no_units.png')
# -*- coding: utf-8 -*-
"""
Created on Mon May 30 20:35:35 2016

@author: Ben
"""
import clearplot.plot_functions as pf

#Verification that multiple y axes and linked x axes work properly
[fig, ax1, curves] = pf.plot('', [0,1], [0,1], x_label = 'x', y_label = 'y1')
ax2 = fig.add_axes(share_x_ax = ax1)
ax2.y_tick = 0.1
ax2.y_label = ['y2']
ax2.plot([0,2], [0,0.3])
ax1.y_lim = [0.0, 0.4]
ax3 = fig.add_axes(link_x_ax = ax1)
ax3.y_label = ['y3']
ax3.plot([0, 0.6], [0, 0.2])
ax3.y_tick = 0.1
ax3.x_lim = [0, 1.5]
fig.auto_adjust_layout()
fig.save('multiple_y_axes-linked_x_axes')
Пример #11
0
# -*- coding: utf-8 -*-
"""
Created on Mon May 30 21:15:34 2016

@author: Ben
"""

import clearplot.plot_functions as pf
import numpy as np

#Verification that the cropping algorithm works properly with log data
#(Select x values that are nearly the same as the limits on a linear scale, 
#but significantly different on a log scale.  Select y values that are totally 
#within the y limits, so that the data exceeds the x limits and not the y 
#limits.)
xa = np.linspace(5.0e-13, 5.0e-6, 20)
ya = np.linspace(1.0e8, 1.0e11, 20)
#(Select x values that are totally within the x limits, so that the data 
#exceeds the y limits and not the x limits.  Select y values that are 
#significantly  bigger/smaller than limits on a linear scale, but are nearly 
#the same on a log scale.)
xb = np.linspace(1.0e-11, 1.0e-8, 20)
yb = np.linspace(1.0e7 - 0.4e6, 1.0e12 + 0.04e12, 20)
pf.plot('curve_cropping-log_axes', \
    [xa, xb], [ya, yb], \
    x_scale = 'log', y_scale = 'log', \
    x_lim = [1.0e-12, 1.0e-7], y_lim = [1.0e7, 1.0e12])
# -*- coding: utf-8 -*-
"""
Created on Mon May 30 20:44:37 2016

@author: Ben
"""

import clearplot.plot_functions as pf
import numpy as np

#Verification that manually picking the label text works properly
xa = np.arange(0,10,0.01)
ya = np.sqrt(xa)
xb = xa
yb = np.log(xa + 1.0)
[fig, ax, curves] = pf.plot('', [xa, xb], [ya, yb], \
	labels = ['\Omega_1', '\Omega_2'], legend = False)
ax.label_curves(pick = 'text')
fig.save('manually_picked_label_text')
# -*- coding: utf-8 -*-
"""
Created on Mon May 30 20:47:40 2016

@author: Ben
"""

import clearplot.plot_functions as pf
import numpy as np

# Verification that manually picking the root of the label works properly
xa = np.arange(0, 10, 0.01)
ya = np.sqrt(xa)
xb = xa
yb = np.log(xa + 1.0)
[fig, ax, curves] = pf.plot("", [xa, xb], [ya, yb], labels=["\Omega_1", "\Omega_2"], legend=False)
ax.label_curves(pick="root", angles=[120, -60])
fig.save("manually_picked_label_root")
Пример #14
0
    'source', 'data')
path = os.path.join(data_dir, 's140302C-mechanical_response.csv')
data = np.loadtxt(path, delimiter = ',')
#Specify the indices of the field images to be plotted
ndx_list = [0, 85, 141, 196, 252]
#Specify the column indices to crop the images to
cols = range(470,470+340)
#Load the field images into an image sequence list
im_seq = []
for ndx in ndx_list:
    #Load field image
    im_filename = 's140302C-eqps_field-frame_%r.png' %(ndx)
    im_path = os.path.join(data_dir, 'hi-rez_field_images', im_filename)
    im = scipy.misc.imread(im_path)
    #Crop the field image and add to list
    im_seq.append(im[:,cols,:])
#Create labels
labels = range(1, len(ndx_list) + 1)
labels = map(lambda x: str(x), labels)

#Plot curve
[fig, ax, curves] = pf.plot('', data[:,0], data[:,1], \
	x_label = ['\varepsilon', '\%'], y_label = ['\sigma', 'GPa'])
ax.label_curve(curves[0], labels, ndx = ndx_list, angles = 60)
ax.plot_markers(data[ndx_list,0], data[ndx_list,1], colors = [0,0,0])
fig.save('curve_and_image_sequence-a.png');
#Plot image sequence
[fig, ax, im_obj] = pf.show_im('curve_and_image_sequence-b.png', \
    im_seq, scale_im = 0.3,  c_label = ['\bar{\varepsilon}^p', '\%'], \
    c_lim = [0, 100], c_tick = 25, b_labels = True, im_interp = 'bicubic', \
    c_bar = True);
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 15:21:16 2015

@author: Ben
"""
import clearplot.plot_functions as pf
import numpy as np

xa = np.arange(0, 1.001, 0.001)
ya = np.sqrt(0.0625 - ((xa-0.5)/2.0)**2.0) * 8.0
xa = np.append(xa, np.flipud(xa))
ya = np.append(ya, -np.flipud(ya))
xb = xa * 2.35
yb = ya * 1.5

[fig, ax, curves] = pf.plot('', [xa, xb], [ya, yb], \
    x_label = ['\lambda_{zz}'], y_label = ['\rho_{r\theta}', 'Btu']);
ax.x_tick_labels = ['0', '\pi/2', '\pi', '3\pi/2', '2\pi', '5\pi/4']
ax.y_tick_labels = ['\alpha', '', '0', '', '\beta']
ax.add_arrowheads_to_curves(ndx = [[800, 1300], [800, 1300]])
fig.save('arrows-custom_tick_labels.png')
Пример #16
0
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 15:19:31 2015

@author: Ben
"""
import clearplot.plot_functions as pf
import numpy as np

x = np.array([33.0, 4.0, 1.0, 1.0/7.0, 1.0/10.0, 1.0/25.0, 1.0/60.0, \
    1.0/120.0, 1.0/439.0, 1.0/645.0])
y = 4.0 * x**0.5 

pf.plot('log_log_plot.png', x, y, \
    x_label = ['h\,/\,h_o'], y_label = ['e'], \
    x_scale = 'log', y_scale = 'log', x_lim = ['auto', 1000], \
    marker_shapes = 'o', marker_edge_widths = 0)
Пример #17
0
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 15:04:55 2015

@author: Ben
"""
import clearplot.plot_functions as pf
import numpy as np

x = np.arange(0,10,0.01)
y = np.sqrt(x)
pf.plot('bare_bones.png', x, y);