예제 #1
0
#!/usr/local/bin/python
from mpltools import style
from scipy.io import loadmat
import numpy as np
import matplotlib.pyplot as plt
import mympltools as util
import matpyplot

if __name__ == "__main__":
    ax = matpyplot.draw('ballistic_trajectory.mat')
    lim = ax.axis("image")
    ax.set_xticks(np.arange(0, lim[1] + 1, 10))
    ax.set_yticks(np.arange(0, lim[3] + 1, 10))
    util.padaxis(ax, 0.03, l=lim)
    #ax.grid()

    ax.get_figure().savefig('ballistic_trajectory.pdf')
예제 #2
0
def draw(dataFileName):
	A = np.array # shortcut

	style.use('dippa')


	
	cycle = plt.rcParams["axes.color_cycle"]
	defc = ['b', 'g', 'r', 'c', 'm', 'y', 'k']
	
	inp = loadmat(dataFileName,squeeze_me=True,struct_as_record=False)
			
	try:
		xlabel = inp["xlabel"]
	except KeyError as e:
		xlabel = None
	try:
		ylabel = inp["ylabel"]
	except KeyError as e:
		ylabel = None
	try:
		title = inp["title"]
	except KeyError as e:
		title = None

	try:
		legend = inp["legend"]
	except KeyError as e:
		legend = None

	try:
		legendkw = _todict(inp["legendkw"])
	except KeyError as e:
		legendkw = {}

	try:
		w = inp["w"]
	except KeyError as e:
		w = 5

	try:
		margins = {'margins': inp["margins"]}
	except KeyError as e:
		margins = {}
	
	try:
		margins['figh'] = inp["h"]
	except KeyError:
		pass
	
	try:
		alpha = inp["alpha"]
	except KeyError as e:
		alpha = 0.05

	try:
		axlim = inp["axis"]
	except KeyError as e:
		axlim = None

	try:
		ticklabels = inp["ticklabels"]
	except KeyError as e:
		ticklabels = None

	fig,ax = util.getpadfigure(w,**margins)

	# plot
	lines = []
	for k,triplet in enumerate(inp["data"]):
		if len(triplet) < 2:
			continue
		if len(triplet) > 2 and type(triplet[2]) is not unicode:
			triplet[2] = ""
		arg = triplet[0:3]
		#print(arg)
		kw = _setcolor(triplet,cycle,defc,k)
		lines.append(ax.plot(*arg,**kw)[0])

		#print(kw)
		#if kw.has_key("yerr"):
		#	kw["ax"] = ax
		#	errorfill(arg[0],arg[1],**kw)
		#else:
		#	ax.plot(*arg,**kw)
		ax.hold(True)
	
	util.padaxis(ax,alpha,l=axlim)

	if title is not None:
		ax.set_title(title,family='serif')
	if xlabel is not None:
		xlabel = ax.set_xlabel(xlabel,family='serif')
	if ylabel is not None:
		ylabel = ax.set_ylabel(ylabel,family='serif')
	if legend is not None:
		#print(legend)
		#print(lines)
		lg = ax.legend(lines,legend.flat,**legendkw)
		# if xlabel is not None:
		# 	for text in lg.get_texts():
		# 		text.set_color(xlabel.get_color())
		for text in lg.get_texts():
			text.set_family('serif')
	if ticklabels is not None:
		if not ticklabels[0]:
			ax.set_xticklabels([])
		if not ticklabels[1]:
			ax.set_yticklabels([])
			
	return(ax)
예제 #3
0
#!/usr/local/bin/python
from mpltools import style
from scipy.io import loadmat
import numpy as np
import matplotlib.pyplot as plt
import mympltools as util
import matpyplot

if __name__ == "__main__":
    ax = matpyplot.draw('ballistic_trajectory.mat')
    lim = ax.axis("image")
    ax.set_xticks(np.arange(0,lim[1]+1,10))
    ax.set_yticks(np.arange(0,lim[3]+1,10))
    util.padaxis(ax,0.03,l=lim)
    #ax.grid()

    ax.get_figure().savefig('ballistic_trajectory.pdf')	
예제 #4
0
파일: matpyplot.py 프로젝트: dennari/thesis
def draw(dataFileName):
    A = np.array  # shortcut

    style.use("dippa")

    cycle = plt.rcParams["axes.color_cycle"]
    defc = ["b", "g", "r", "c", "m", "y", "k"]

    inp = loadmat(dataFileName, squeeze_me=True, struct_as_record=False)

    try:
        xlabel = inp["xlabel"]
    except KeyError as e:
        xlabel = None
    try:
        ylabel = inp["ylabel"]
    except KeyError as e:
        ylabel = None
    try:
        title = inp["title"]
    except KeyError as e:
        title = None

    try:
        legend = inp["legend"]
    except KeyError as e:
        legend = None

    try:
        legendkw = _todict(inp["legendkw"])
    except KeyError as e:
        legendkw = {}

    try:
        w = inp["w"]
    except KeyError as e:
        w = 5

    try:
        margins = {"margins": inp["margins"]}
    except KeyError as e:
        margins = {}

    try:
        margins["figh"] = inp["h"]
    except KeyError:
        pass

    try:
        alpha = inp["alpha"]
    except KeyError as e:
        alpha = 0.05

    try:
        axlim = inp["axis"]
    except KeyError as e:
        axlim = None

    try:
        ticklabels = inp["ticklabels"]
    except KeyError as e:
        ticklabels = None

    fig, ax = util.getpadfigure(w, **margins)

    # plot
    lines = []
    for k, triplet in enumerate(inp["data"]):
        if len(triplet) < 2:
            continue
        if len(triplet) > 2 and type(triplet[2]) is not unicode:
            triplet[2] = ""
        arg = triplet[0:3]
        # print(arg)
        kw = _setcolor(triplet, cycle, defc, k)
        lines.append(ax.plot(*arg, **kw)[0])

        # print(kw)
        # if kw.has_key("yerr"):
        # 	kw["ax"] = ax
        # 	errorfill(arg[0],arg[1],**kw)
        # else:
        # 	ax.plot(*arg,**kw)
        ax.hold(True)

    util.padaxis(ax, alpha, l=axlim)

    if title is not None:
        ax.set_title(title, family="serif")
    if xlabel is not None:
        xlabel = ax.set_xlabel(xlabel, family="serif")
    if ylabel is not None:
        ylabel = ax.set_ylabel(ylabel, family="serif")
    if legend is not None:
        # print(legend)
        # print(lines)
        lg = ax.legend(lines, legend.flat, **legendkw)
        # if xlabel is not None:
        # 	for text in lg.get_texts():
        # 		text.set_color(xlabel.get_color())
        for text in lg.get_texts():
            text.set_family("serif")
    if ticklabels is not None:
        if not ticklabels[0]:
            ax.set_xticklabels([])
        if not ticklabels[1]:
            ax.set_yticklabels([])

    return ax