本文整理汇总了Python中matplotlib2tikz.tikz_save函数的典型用法代码示例。如果您正苦于以下问题:Python tikz_save函数的具体用法?Python tikz_save怎么用?Python tikz_save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tikz_save函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: compplot_deviations
def compplot_deviations(jsonfilelist, fignum=333, figname="figdiff", compress=10):
""" compute the deviations of the measured output from the stable
state output
"""
import matplotlib.cm as cm
fig = plt.figure(fignum)
ax1 = fig.add_subplot(111)
diffnormlist = []
collin = np.linspace(0.2, 0.7, len(jsonfilelist))
for k, jsfstr in enumerate(jsonfilelist):
jsf = dou.load_json_dicts(jsfstr)
tmesh = jsf["tmesh"]
redinds = range(0, len(tmesh), compress)
redina = np.array(redinds)
outsig = np.array(jsf["outsig"])
# two norm at the differences
outsigdiff = np.sqrt(((outsig - outsig[0, :]) * (outsig - outsig[0, :])).sum(axis=1))
diffnormlist.append((tmesh[-1] - tmesh[0]) / len(tmesh) * outsigdiff.sum())
curline, = ax1.plot(
np.array(tmesh)[redina], outsigdiff[redina], c=cm.CMRmap(collin[k]), linewidth=2.0, label="{0}".format(k)
)
handles, labels = ax1.get_legend_handles_labels()
ax1.legend(handles, labels, loc="lower right")
tikz_save(figname + "{0}".format(fignum) + ".tikz", figureheight="\\figureheight", figurewidth="\\figurewidth")
print "saved to " + figname + "{0}".format(fignum) + ".tikz"
fig.show()
print diffnormlist
print len(tmesh)
开发者ID:highlando,项目名称:lqgbt-oseen,代码行数:34,代码来源:pltdatascompare.py
示例2: save_records_plot
def save_records_plot(file_path, ls_monitors, name, n_train_batches, legend_loc="upper right"):
"""
Save a plot of a list of monitors' history.
Args:
file_path (string): the folder path where to save the plot
ls_monitors: the list of statistics to plot
name: name of file to be saved
n_train_batches: the total number of training batches
"""
lines = ["--", "-", "-.",":"]
linecycler = cycle(lines)
plt.figure()
for m in ls_monitors:
X = [i/float(n_train_batches) for i in m.history_minibatch]
Y = m.history_value
a, b = zip(*sorted(zip(X, Y)))
plt.plot(a, b, next(linecycler), label=m.name)
plt.xlabel('Training epoch')
plt.ylabel(ls_monitors[0].type)
plt.legend(loc=legend_loc)
plt.locator_params(axis='y', nbins=7)
plt.locator_params(axis='x', nbins=10)
plt.savefig(file_path + name + ".png")
tikz_save(file_path + name + ".tikz", figureheight = '\\figureheighttik', figurewidth = '\\figurewidthtik')
开发者ID:adbrebs,项目名称:spynet,代码行数:27,代码来源:monitor.py
示例3: f_conv_plot
def f_conv_plot(fval_0sr1, fval_prox_grad):
"""
"""
import matplotlib.pyplot as plt
from matplotlib2tikz import save as tikz_save
fval_0sr1.insert(0, f(x0))
fval_prox_grad.insert(0, f(x0))
fval_l_bfgs_b.insert(0, f_l_bfgs_b(x0_l_bfgs_b))
fval_l_bfgs_b.insert(0, f_l_bfgs_b(x0_l_bfgs_b))
line1, = plt.plot(range(len(fval_0sr1)), fval_0sr1, 'r', label = '0SR1', lw = 2)
line2, = plt.plot(range(len(fval_prox_grad)), fval_prox_grad, 'b', label = 'ProxGrad', lw = 2)
line3, = plt.plot(range(len(fval_l_bfgs_b)), fval_l_bfgs_b, 'g', label = 'L-BFGS-B', lw = 2)
#plt.xscale('log')
#plt.xlim([0, 1e2])
plt.yscale('log')
#plt.ylim([0, 1e5])
plt.ylabel('Function Value')
plt.xlabel('Number of Iterations')
plt.legend(handles = [line1, line2, line3])
tikz_save( 'ProxPDE.tikz' );
plt.show()
return
开发者ID:heidekrueger,项目名称:CaseStudiesMachineLearning,代码行数:27,代码来源:ProxTest_PDE.py
示例4: save_plot
def save_plot(self, argument=None, name='plot', path='images/', **kwargs):
from matplotlib2tikz import save as tikz_save
directory = path
if not os.path.isdir(directory):
os.makedirs(directory)
plot = self.plot(argument, **kwargs)
info = plot['info']
proj_3d = False
for k, _ in enumerate(info):
for l, _ in enumerate(info[0]):
if ('projection' in info[k][l] and
info[k][l]['projection'] == '3d'):
proj_3d = True
if proj_3d:
warnings.warn('3D plotting is not supported by matplotlib2tikz. ' +
'Saving to pdf instead.')
path = directory+'/'+name+'.pdf'
plt.savefig(path, bbox_inches='tight', pad_inches=0)
else:
figurewidth = kwargs[
'figurewidth'] if 'figurewidth' in kwargs else '8cm'
figureheight = kwargs[
'figureheight'] if 'figureheight' in kwargs else None
path = directory+'/'+name+'.tikz'
if figureheight is None:
tikz_save(path, figurewidth=figurewidth)
else:
tikz_save(
path, figurewidth=figurewidth, figureheight=figureheight)
_cleanup_rubbish(path, info)
开发者ID:meco-group,项目名称:omg-tools,代码行数:30,代码来源:plotlayer.py
示例5: save_tex
def save_tex(filename, **kwargs):
"""
Save figure created with script 'filename' to a tex file using
matplotlib2tikz. Output directory is figures/. You can specify a
subdirectory using the 'subdir' kwarg.
Valid kwargs: addFigureDims and anything passed to matplotlib2tikz.save().
figureheight and -width variables will be added if addFigureDims is true.
Pass a 'suffix' if you generate multiple plots from one script.
:param filename | __file__ of the plotting script
addFigureDims | bool
"""
from matplotlib2tikz import save as tikz_save
import os.path
addFigureDims = kwargs.pop("addFigureDims", False)
kwargs["figurewidth"] = '\\figurewidth' if addFigureDims else None
kwargs["figureheight"] = '\\figureheight' if addFigureDims else None
suffix = kwargs.pop("suffix", "")
subdir = kwargs.pop("subdir", "")
kwargs["tex_relative_path_to_data"] = os.path.join("figures", subdir)
if len(subdir):
subdir += os.path.sep
tikz_save(
'../figures/{}{}{}.tex'.format(
subdir,
os.path.basename(filename).split('.')[0],
suffix),
**kwargs)
开发者ID:pylipp,项目名称:mscthesis,代码行数:28,代码来源:utils.py
示例6: save_movie
def save_movie(self, signal, name='movie', path='movies/', **kwargs):
from matplotlib2tikz import save as tikz_save
directory = path + name
if not os.path.isdir(directory):
os.makedirs(directory)
t = self.vehicles[0].signals['time']
if ('number_of_frames' in kwargs and
kwargs['number_of_frames'] <= (t.shape[1]-1)):
number_of_frames = kwargs['number_of_frames']
else:
number_of_frames = t.shape[1]-1
root = kwargs['root'] if 'root' in kwargs else None
figurewidth = kwargs['figurewidth'] if 'figurewidth' in kwargs else '8cm'
figureheight = kwargs['figureheight'] if 'figureheight' in kwargs else None
subsample = (t.shape[1]-2)/(number_of_frames-1)
kwargs['no_update'] = True
plot = self.show(signal, **kwargs)
cnt = 0
for k in range(0, t.shape[1]-1, subsample):
self.update(k, plots=plot)
if signal == 'scene':
plt.axis('off')
path = directory+'/'+name+'_'+str(cnt)+'.tikz'
if figureheight is None:
tikz_save(path, figurewidth=figurewidth)
else:
tikz_save(path, figurewidth=figurewidth, figureheight=figureheight)
self._cleanup_rubbish(path, root)
cnt += 1
开发者ID:jgillis,项目名称:omg-tools,代码行数:29,代码来源:plots.py
示例7: compplotfreqresps
def compplotfreqresps(jsonfilelist, fignum=444, figname="freqfigdiff", compress=1):
""" plot the errors in the freqresp for various configurations
Parameters:
-----------
jsonfilelist : list
of json files as produced by `btu.compare_freqresp`
"""
import matplotlib.cm as cm
fig = plt.figure(fignum)
ax1 = fig.add_subplot(111)
collin = np.linspace(0.2, 0.7, len(jsonfilelist))
for k, jsfstr in enumerate(jsonfilelist):
jsf = dou.load_json_dicts(jsfstr)
tmesh = jsf["tmesh"]
redinds = range(0, len(tmesh), compress)
redina = np.array(redinds)
outsig = np.array(jsf["diffsysfr"])
curline, = ax1.plot(
np.array(tmesh)[redina], outsig[redina], c=cm.CMRmap(collin[k]), linewidth=2.0, label="{0}".format(k)
)
handles, labels = ax1.get_legend_handles_labels()
ax1.legend(handles, labels, loc="lower left")
tikz_save(figname + "{0}".format(fignum) + ".tikz", figureheight="\\figureheight", figurewidth="\\figurewidth")
print "saved to " + figname + "{0}".format(fignum) + ".tikz"
ax1.semilogx()
ax1.semilogy()
fig.show()
开发者ID:highlando,项目名称:lqgbt-oseen,代码行数:33,代码来源:pltdatascompare.py
示例8: prox_comparison
def prox_comparison():
import matplotlib.pyplot as plt
import StochProxGrad as spg
import StochProxMeth as spm
import ProxMeth as pm
import ProxGrad as pg
from matplotlib2tikz import save as tikz_save
fval_pm = pm.compute_0sr1(fn, gfn, x0, l_reg = l, tau = 1 / L, batch_size = batch_size)
fval_pg = pg.proximal_gradient(fn, gfn, x0, 1 / L, l_reg = l, batch_size = batch_size)
fval_spm = spm.compute_0sr1(f, gf, x0, X, y, l_reg = l, tau = 1 / L, batch_size = batch_size)
fval_spg = spg.proximal_gradient(f, gf, x0, 1 / L, X, y, l_reg = l, batch_size = batch_size)
fval_pm.insert(0, f(x0, X, y))
fval_pg.insert(0, f(x0, X, y))
fval_spm.insert(0, f(x0, X, y))
fval_spg.insert(0, f(x0, X, y))
line1, = plt.plot(range(len(fval_pm)), fval_pm, 'r', label = '0SR1', lw = 2)
line2, = plt.plot(range(len(fval_pg)), fval_pg, 'b', label = 'PG', lw = 2)
line3, = plt.plot(range(len(fval_spm)), fval_spm, 'g', label = 'S0SR1', lw = 2)
line4, = plt.plot(range(len(fval_spg)), fval_spg, 'k', label = 'SPG', lw = 2)
#plt.xlim([0, 55])
plt.yscale('log')
#plt.ylim([1e1, 1e13])
plt.ylabel('Function Value')
plt.xlabel('Number of Iterations')
plt.legend(handles = [line1, line2, line3, line4])
tikz_save( 'StochProx_150.tikz' );
return
开发者ID:heidekrueger,项目名称:CaseStudiesMachineLearning,代码行数:33,代码来源:StochProxTest_Normal1.py
示例9: perf_profile
def perf_profile():
erreur_abs=[0,2,5,10,15,20,25] #erreur relative!
wpp1=[91.8,91.8,95.9,100,100,100,100]
wpp2=[95.9,95.9,97.9,100,100,100,100]
#wpp3=[]
#dsatur1=[93.1,93.1,93.1,96.5,96.5,100,100]
dsatur2=[97.9,97.9,97.9,100,100,100,100]
#szekeres=[89.6,89.6,93.1,96.5,96.5,100,100]
#rlf1=[93.1,93.1,93.1,96.5,96.5,100,100]
rlf2=[97.9,97.9,97.9,100,100,100,100]
plt.xlim(-0.2,15)
plt.ylim(87,102)
plt.xlabel("Relative error compared to optimal solution")
plt.ylabel("Proportion of tests solved")
plt.title("Performance profile, |V|=25")
plot1,=plt.plot(erreur_abs,wpp1,'^-',color='0.3')
plot2,=plt.plot(erreur_abs,wpp2,'s-',color='0.3')
#plot3,=plt.plot(erreur_abs,dsatur1,'o--',color='g')
plot4,=plt.plot(erreur_abs,dsatur2,'v-',color='0.3')
#plot5,=plt.plot(erreur_abs,szekeres,'v--',color='y')
#plot6,=plt.plot(erreur_abs,rlf1,'<--',color='c')
plot7,=plt.plot(erreur_abs,rlf2,'s-',color='0.3')
plt.legend([plot1,plot2,plot4,plot7],
["WP1","WP2","DSAT","RLF"],loc="lower right")
tikz_save('/Users/romainmontagne/Desktop/Projet/article/article v3/perf_profile2.tikz',
figureheight = '\\figureheight',
figurewidth = '\\figurewidth')
开发者ID:Kuifje02,项目名称:PDWICP,代码行数:33,代码来源:plots.py
示例10: saveTikzPng
def saveTikzPng(filename, watermark=None, thesis=False, show=False):
if watermark is not None:
plt.gcf().text(0.125, 0.9, watermark, fontsize=8)
filename_png = filename + '.png'
filename_pdf = filename + '.pdf'
fig = plt.gcf()
# plt.plot()
d = os.getcwd()
figure_folder = os.path.join(d, 'figures')
tex_folder = os.path.join(d, 'tex')
if not os.path.exists(tex_folder):
os.makedirs(tex_folder)
if not os.path.exists(figure_folder):
os.makedirs(figure_folder)
tikz_save(
tex_folder + "/" + filename + '.tex',
figureheight='\\figureheight',
figurewidth='\\figurewidth'
)
if thesis == False:
fig.savefig(figure_folder + "/" + filename_png,
format='png', dpi=600, bbox_inches='tight')
else:
fig.savefig(figure_folder + "/" + filename_pdf,
format='pdf', dpi=600, bbox_inches='tight')
fig.savefig(figure_folder + "/" + filename_png,
format='png', dpi=600, bbox_inches='tight')
if show == True:
plt.show()
开发者ID:DavidRobertQuinn,项目名称:IV,代码行数:29,代码来源:data_extractor.py
示例11: BarPlot
def BarPlot(
figName,
fun0,
funOpt,
funLabel0,
funLabelOpt,
xLabel,
yLabel,
ResultsFolder,
OptName,
figType=FileTypeRendered,
Color0="#FAA43A",
ColorOpt="#5DA5DA",
figsizex=6,
figsizey=3,
width=0.5,
xspacing=0.25,
dpi=200,
xtick=True,
usetex=False,
Tikz=False,
):
plt.rc("text", usetex=usetex)
Plot = plt.figure(figsize=(figsizex, figsizey), dpi=dpi)
ax = Plot.add_subplot(111)
nf = np.size(fun0)
ind = np.arange(nf)
rects1 = ax.bar(ind + xspacing * 2.5, fun0, width, color=Color0)
rects2 = ax.bar(ind + xspacing * 2.5 + width / 2, funOpt, width, color=ColorOpt)
lgd = ax.legend(
(rects1[0], rects2[0]),
(funLabel0, funLabelOpt),
frameon=False,
prop=fontP,
bbox_to_anchor=(1.05, 1),
loc=2,
borderaxespad=0.0,
)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position("left")
ax.xaxis.set_ticks_position("bottom")
ax.xaxis.set_major_locator(ticker.MaxNLocator(integer=True))
plt.xlim(xmin=xspacing * 2, xmax=nf + width / 2 + xspacing)
plt.ylim(ymin=np.min((np.min(fun0), np.min(funOpt), 0.0)), ymax=np.max((np.max(fun0), np.max(funOpt))))
if xtick == False:
plt.tick_params(axis="x", which="both", bottom="off", labelbottom="off")
plt.xlabel(xLabel)
plt.ylabel(yLabel)
plt.tight_layout()
for ii in range(np.size(figType)):
plt.savefig(
ResultsFolder + OptName + "_" + figName + "." + figType[ii], bbox_extra_artists=(lgd,), bbox_inches="tight"
)
if Tikz == True:
tikz_save(ResultsFolder + OptName + "_" + figName + ".tikz")
plt.close()
fail = 0
return fail
开发者ID:LordTofu,项目名称:DesOptPy,代码行数:59,代码来源:OptResultReport.py
示例12: SingleConvPlot
def SingleConvPlot(
figName,
data,
dataLabel,
xLabel,
yLabel,
ResultsFolder,
OptName,
figType=FileTypeRendered,
figsizex=6,
figsizey=3,
width=0.5,
xspacing=0.25,
dpi=200,
xtick=True,
usetex=False,
Tikz=False,
labelSubscripts=True,
):
plt.rc("text", usetex=usetex)
Plot = plt.figure(figsize=(figsizex, figsizey), dpi=dpi)
ax = Plot.add_subplot(111)
jet = plt.get_cmap("jet")
cNorm = colors.Normalize(vmin=0, vmax=len(data[0]))
scalarMap = cm.ScalarMappable(norm=cNorm, cmap=jet)
for n in range(np.size(data[0])):
if labelSubscripts == True:
if usetex == True:
ax.plot(data[:, n], color=scalarMap.to_rgba(n), label=dataLabel % str(n + 1))
else:
ax.plot(data[:, n], color=scalarMap.to_rgba(n), label=dataLabel % str(n + 1))
else:
ax.plot(data[:, n], color=scalarMap.to_rgba(n), label=dataLabel)
plt.xlabel(xLabel)
plt.ylabel(yLabel)
plt.xlim(xmin=0, xmax=len(data) - 1)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position("left")
ax.xaxis.set_ticks_position("bottom")
ax.xaxis.set_major_locator(ticker.MaxNLocator(integer=True))
numColx = (np.size(data[0]) / 12) + 1
if numColx > 3:
numColx = 3
plt.yticks(size=10 + (numColx - 1) * 4)
lgd = ax.legend(bbox_to_anchor=[1.05, 1], loc=2, ncol=numColx, frameon=False, prop=fontPP)
plt.tight_layout()
for ii in range(np.size(figType)):
plt.savefig(
ResultsFolder + OptName + "_" + figName + "." + figType[ii], bbox_extra_artists=(lgd,), bbox_inches="tight"
)
if Tikz == True:
tikz_save(ResultsFolder + OptName + "_" + figName + ".tikz")
plt.close()
fail = 0
return fail
开发者ID:LordTofu,项目名称:DesOptPy,代码行数:56,代码来源:OptResultReport.py
示例13: graph
def graph(datamodel, target_list, selected_metrics, name_replace_list):
xdata = []
ydata = []
for i, target in enumerate(target_list):
# Read data and initialize data model
f = open(target, 'r')
target_data = datamodel(f.read())
if i == 0:
# On first pass, create header list
first = target_data
if selected_metrics is None:
metrics = target_data.get_all_titles()
else:
metrics = target_data.get_title_list(selected_metrics)
else:
# On subsequent passes, ensure they all have the same metrics and titles
first.check_titles_match(target_data)
# Perform find/replace on filename
target_name = target
for (fstr, rstr) in name_replace_list:
target_name = target_name.replace(fstr, rstr)
xdata.append(target_name)
# Append all the data
if selected_metrics is None:
ydata.append(target_data.get_all_data())
else:
ydata.append(target_data.get_data_list(selected_metrics))
ydata = transpose(ydata)
# Create graph
fig = plt.figure()
x = range(len(xdata))
for i, metric in enumerate(metrics):
plt.plot(x, ydata[i], 'o-', lw=4.0, label=metric)
# Set temporary x-axis to text xdata
plt.xticks(x, xdata)
plt.legend(loc='lower right', bbox_to_anchor=(0.5, -0.05))
# Write to a temporary file,
filename = "graph.tmp"
tikz_save(filename)
plt.close(fig)
# get the string from that file,
f = open(filename, 'r')
graph_data = f.read()
# remove the file,
f.close()
os.remove(filename)
# then return the string
return graph_data
开发者ID:fubuloubu,项目名称:GuitarView,代码行数:55,代码来源:print_data_model.py
示例14: plot
def plot(name, qualities_mes, costs_mes, qualities_th, costs_th):
fig, axes = plt.subplots(2,1)
ax1= axes[0]
texts_mes= []
for (i, (quality, cost)) in enumerate(zip(qualities_mes, costs_mes)):
texts_mes.append(ax1.text(quality, cost, str(i), ha='center', va='center'))
#print("Measured: ", q, c_cycle)
color='tab:red'
ax1.set_ylabel("cost per cycle (µs)")
ax1.set_xlabel("quality")
ax1.scatter(qualities_mes, costs_mes, label="Measured", color=color)
ax1.tick_params(axis='y', labelcolor=color)
ax1.grid(True)
ax2 = axes[1]
texts_th = []
for (i, (quality, cost)) in enumerate(zip(qualities_th, costs_th)):
texts_th.append(ax2.text(quality, cost, str(i), ha='center', va='center'))
color = 'tab:blue'
ax2.set_ylabel("cost")
ax2.set_xlabel("quality")
ax2.scatter(qualities_th, costs_th, label="Model", color=color)
ax2.tick_params(axis='y', labelcolor=color)
ax2.grid(True)
adjust_text(texts_mes, ax=ax1)
adjust_text(texts_th, ax=ax2)
kendalltau = GraphResults("Kendall's tau")
kendalltau.costs = stats.kendalltau(costs_mes, costs_th, nan_policy='raise')
kendalltau.quality = stats.kendalltau(qualities_mes, qualities_th, nan_policy='raise')
spearmanr = GraphResults("Spearman's R")
spearmanr.costs = stats.spearmanr(costs_mes, costs_th, nan_policy='raise')
spearmanr.quality = stats.spearmanr(qualities_mes, qualities_th, nan_policy='raise')
print(kendalltau.name, " Kendal's tau: cost=", kendalltau.costs, " and quality=", kendalltau.quality)
print(spearmanr.name, " Spearman's r: cost=", spearmanr.costs, " and quality=", spearmanr.quality)
fig.tight_layout()
fig.legend()
if args.tikz:
tikz_save(name+".tex")
plt.show()
开发者ID:programLyrique,项目名称:audio-adaptive-scheduling,代码行数:54,代码来源:pipeline.py
示例15: plot_outp_sig
def plot_outp_sig(str_to_json=None, tmeshkey='tmesh', sigkey='outsig',
outsig=None, tmesh=None, fignum=222, reference=None,
tikzstr=None, compress=5, notikz=False):
import matplotlib.pyplot as plt
if str_to_json is not None:
jsdict = load_json_dicts(str_to_json)
tmesh = jsdict[tmeshkey]
outsig = jsdict[sigkey]
else:
str_to_json = 'notspecified'
redinds = list(range(1, len(tmesh), compress))
redina = np.array(redinds)
NY = np.int(len(outsig[0])/2)
fig = plt.figure(fignum)
ax1 = fig.add_subplot(111)
ax1.plot(np.array(tmesh)[redina], np.array(outsig)[redina, :NY],
color='b', linewidth=2.0)
ax1.plot(np.array(tmesh)[redina], np.array(outsig)[redina, NY:],
color='r', linewidth=2.0)
if notikz:
plt.show()
return
try:
from matplotlib2tikz import save as tikz_save
if tikzstr is None:
tikzstr = str_to_json + '{0}'.format(fignum)
tikz_save(tikzstr + '.tikz',
figureheight='\\figureheight',
figurewidth='\\figurewidth'
)
print('tikz saved to ' + tikzstr + '.tikz')
haztikz = True
except ImportError:
haztikz = False
print('cannot save to tikz -- no matplotlib2tikz found')
fig.show()
if reference is not None:
fig = plt.figure(fignum+1)
ax1 = fig.add_subplot(111)
ax1.plot(tmesh, np.array(outsig)-reference)
if haztikz:
tikz_save(str_to_json + '{0}'.format(fignum) + '_difftoref.tikz',
figureheight='\\figureheight',
figurewidth='\\figurewidth'
)
fig.show()
开发者ID:highlando,项目名称:dolfin_navier_scipy,代码行数:54,代码来源:data_output_utils.py
示例16: save
def save(self, signal, name='plot', path='images/', **kwargs):
from matplotlib2tikz import save as tikz_save
directory = path
if not os.path.isdir(directory):
os.makedirs(directory)
self.show(signal, **kwargs)
if signal == 'scene':
plt.axis('off')
figurewidth = kwargs[
'figurewidth'] if 'figurewidth' in kwargs else '8cm'
path = directory+'/'+name+'.tikz'
tikz_save(path, figurewidth=figurewidth)
self._remove_rubbish(path)
开发者ID:jgillis,项目名称:omg-tools,代码行数:13,代码来源:plots.py
示例17: DoubleConvPlot
def DoubleConvPlot(
figName,
data,
dataLabel,
xLabel,
yLabel,
Color,
ResultsFolder,
OptName,
figType=FileTypeRendered,
figsizex=6,
figsizey=3,
width=0.5,
xspacing=0.25,
dpi=200,
xtick=True,
usetex=False,
Tikz=False,
):
plt.rc("text", usetex=usetex)
Plot = plt.figure(figsize=(figsizex, figsizey), dpi=dpi)
ax1 = Plot.add_subplot(111)
ax1.plot(data[0], Color[0], label=dataLabel[0])
plt.xlabel(xLabel)
plt.ylabel(yLabel[0])
ax2 = ax1.twinx()
ax2.plot(data[1], Color[1], label=dataLabel[1])
plt.ylabel(yLabel[1])
handles1, labels1 = ax1.get_legend_handles_labels()
handles2, labels2 = ax2.get_legend_handles_labels()
handles = handles1 + handles2
labels = labels1 + labels2
lgd = ax1.legend(handles, labels, bbox_to_anchor=[1.05, 1], loc=2, frameon=False, prop=fontPP)
plt.xlim(xmin=0, xmax=len(data[0]) - 1)
ax1.spines["right"].set_visible(False)
ax1.spines["top"].set_visible(False)
ax2.spines["top"].set_visible(False)
ax1.yaxis.set_ticks_position("left")
ax1.xaxis.set_ticks_position("bottom")
ax1.xaxis.set_major_locator(ticker.MaxNLocator(integer=True))
plt.tight_layout()
for ii in range(np.size(figType)):
plt.savefig(
ResultsFolder + OptName + "_" + figName + "." + figType[ii], bbox_extra_artists=(lgd,), bbox_inches="tight"
)
if Tikz == True:
tikz_save(ResultsFolder + OptName + "_" + figName + ".tikz")
plt.close()
fail = 0
return fail
开发者ID:LordTofu,项目名称:DesOptPy,代码行数:50,代码来源:OptResultReport.py
示例18: outputplot
def outputplot(tmesh, ycomp, ystar=None, extra=None, fignum=111, fname="notspecified"):
from matplotlib2tikz import save as tikz_save
plt.figure(fignum)
if ystar is not None:
plt.plot(tmesh, ystar, color="b", linewidth=2.0)
lines = plt.plot(tmesh, ycomp)
plt.setp(lines, color="r", linewidth=2.0)
plt.yticks([0.2, 0, -0.2])
# plt.xticks([0, 2])
tikz_save(fname + ".tikz", figureheight="\\figureheight", figurewidth="\\figurewidth", extra=extra)
plt.show(block=False)
开发者ID:highlando,项目名称:optconpy,代码行数:15,代码来源:plot_output.py
示例19: plot_step_resp
def plot_step_resp(str_to_json=None, tmesh=None,
red_stp_rsp=None, ful_stp_rsp=None, inivout=None,
compress=20):
"""
compress : real, optional
factor of compressing for plot, defaults to 20
"""
from matplotlib2tikz import save as tikz_save
if str_to_json is not None:
jsdict = dou.load_json_dicts(str_to_json)
tmesh = np.array(jsdict['tmesh'])
red_stp_rsp = jsdict['red_stp_rsp']
ful_stp_rsp = jsdict['ful_stp_rsp']
inivout = jsdict['inivout']
else:
str_to_json = 'notspecified'
redinds = list(range(0, len(tmesh), compress))
redina = np.array(redinds)
for ccol in range(len(red_stp_rsp)):
# [0, b_mat.shape[1]-1]: # range(2): # b_mat.shape[1]):
fuloutp = np.array(ful_stp_rsp[ccol])-np.array(inivout).T
redoutp = np.array(red_stp_rsp[ccol])
outdiff = fuloutp - redoutp
NY = fuloutp.shape[1]/2
fig = plt.figure(200 + ccol)
ax1 = fig.add_subplot(131)
ax1.plot(tmesh[redina], redoutp[redina, :NY], color='b', linewidth=2.0)
ax1.plot(tmesh[redina], redoutp[redina, NY:], color='r', linewidth=2.0)
ax2 = fig.add_subplot(132)
ax2.plot(tmesh[redina], fuloutp[redina, :NY], color='b', linewidth=2.0)
ax2.plot(tmesh[redina], fuloutp[redina, NY:], color='r', linewidth=2.0)
ax3 = fig.add_subplot(133)
ax3.plot(tmesh[redina], outdiff[redina, :NY], color='b', linewidth=2.0)
ax3.plot(tmesh[redina], outdiff[redina, NY:], color='r', linewidth=2.0)
tikz_save(str_to_json + '{0}'.format(200+ccol) + '.tikz',
figureheight='\\figureheight',
figurewidth='\\figurewidth'
)
print('saved to ' + str_to_json + '{0}'.format(200+ccol) + '.tikz')
fig.show()
开发者ID:highlando,项目名称:sadptprj_riclyap_adi,代码行数:47,代码来源:bal_trunc_utils.py
示例20: plot_blocks_throughput
def plot_blocks_throughput(self, data, data_2):
nblocks = data[6]
nblocks_2 = data_2[6]
# print "data 6 ", data[6]
# print "data 7 ", data[7]
# data[7] gives minimum
# data[8] gives average
# data[9] gives variance
block_dict = data[8]
block_dict_2 = data_2[8]
self.blks_x = numpy.array(xrange(nblocks))
self.blks_x_2 = numpy.array(xrange(nblocks_2))
sorted_dict = sorted(block_dict.iteritems(), key=operator.itemgetter(0))
sorted_dict.reverse()
self.blks_times = [s[1] for s in sorted_dict]
self.blks_keys = [s[0] for s in sorted_dict]
sorted_dict_2 = sorted(block_dict_2.iteritems(), key=operator.itemgetter(0))
sorted_dict_2.reverse()
self.blks_times_2 = [s[1] for s in sorted_dict_2]
self.blks_keys_2 = [s[0] for s in sorted_dict_2]
self.fig100 = plt.figure(100 + self.fignum, figsize=(12, 10), facecolor="w")
self.fig100.clf()
self.sp101 = self.fig100.add_subplot(1, 1, 1)
self.blks_times[:] = [x / self.nitems * 1000 for x in self.blks_times]
print "SUMSUM: ", sum(self.blks_times)
self.blks_times_2[:] = [x / self.nitems * 1000 for x in self.blks_times_2]
print "self.blks_times ", self.blks_times
self.sp101.barh(self.blks_x, self.blks_times, height=width, color="r", alpha=0.85, label="2.5 MHz")
self.sp101.barh(self.blks_x_2 + width, self.blks_times_2, height=width, color="b", alpha=0.85, label="1 MHz")
# print self.blks_times
self.sp101.set_title(self.title, fontsize=22, fontweight="bold")
self.sp101.set_xlabel("Execution time per OFDM symbol (us)", fontsize=16)
self.sp101.set_yticks(self.blks_x + width)
self.sp101.set_yticklabels(self.blks_keys)
self.sp101.grid()
self.sp101.legend()
# self.sp101.set_color_cycle(['c', 'm', 'y', 'k'])
plt.draw()
tikz_save("myfile.tikz", figureheight="20cm", figurewidth="14cm")
开发者ID:rwth-ti,项目名称:gr-ofdm,代码行数:45,代码来源:plot_results_transceiver.py
注:本文中的matplotlib2tikz.tikz_save函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论