Exemplo n.º 1
0
import ltLaTeXpyplot as lt

# Create figure
fig = lt.ltFigure(name='fig', tight_layout=True)

# Define what to plot
t = np.arange(0.01, 10.0, 0.01)
s1 = np.exp(t)
s2 = np.sin(2 * np.pi * t)

# Define graphs
fig.addgraph('graph1', x_label='time (s)', y_label='exp')
fig.addtwingraph('graph2', 'graph1', y_label='sin', axis='x')

# Insert object in plots
exp = lt.ltPlotFct(t, s1, color='b')
sin = lt.ltPlotPts(t, s2, color='r', marker='.')

# Add fit line
sin.plot(fig, 'graph2')
exp.plot(fig, 'graph1')

ax1 = fig.graphs['graph1'].graph
ax1.set_ylabel(fig.graphs['graph1'].y_label, color='b')
ax1.tick_params('y', colors='b', which='major')
ax1.tick_params('y', colors='b', which='minor')
ax2 = fig.graphs['graph2'].graph
ax2.set_ylabel(fig.graphs['graph2'].y_label, color='r')
ax2.tick_params('y', colors='r', which='major')
ax2.tick_params('y', colors='r', which='minor')
Exemplo n.º 2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

import ltLaTeXpyplot as lt

# Create figure
fig = lt.ltFigure(name='fig')

# Define what to plot
x = np.array([1.0, 2.1, 3.1, 3.9])
y = np.array([2.1, 3.9, 6.1, 7.8])
y2 = np.array([3.0, 6.1, 8.3, 10.5])

fct1 = lt.ltPlotFct(x, y, label='F1', color='C3')
fct2 = lt.ltPlotPts(x, y2, label='F2')

# Define graphs
fig.addgraph('graph1')

# Insert object in plots
fct1.plot(fig, 'graph1')
fct2.plot(fig, 'graph1')

# Fill area
fig.graphs['graph1'].fill_between(x, y, y2, label='Area', color='C2')

# Save figure
fig.save(format='pdf')
Exemplo n.º 3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

import ltLaTeXpyplot as lt

# Create figure
fig = lt.ltFigure(name='fig')

# Define what to plot
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

function = lt.ltPlotFct(t, s)

# Define graphs
fig.addgraph('graph1',
             x_label='time (s)',
             y_label='voltage (mV)',
             title='About as simple as it gets, folks',
             show_grid=True)

# Insert object in plots
function.plot(fig, 'graph1')

# Save figure
fig.save(format='pdf')
x = mu + sigma * np.random.randn(437)

num_bins = 50

# Define graphs
fig.addgraph('graph1',
             x_label='Smarts',
             y_label='Probability density',
             title='Histogram of IQ: $\\mu=100$, $\\sigma=15$',
             y_scaling='log',
             y_min=.75e-4,
             y_max=0.05,
             num_y_major=False)

# Insert object in plots
hist = lt.ltPlotHist(data=x, bins=num_bins, range=[50, 150], fill=True)
hist.SetIntegral(1)  # get a probability
hist.plot(fig, 'graph1')

# Add fit line
bins = hist.bins
y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-0.5 * (1 / sigma *
                                                         (bins - mu))**2))

fct = lt.ltPlotFct(bins, y, color='C1', dashes=[4, 1.5])

fig.addplot(fct, 'graph1')

# Save figure
fig.save(format='pdf')
Exemplo n.º 5
0
r_on_a0 = np.arange(0, data.r_on_a0_MAX, 0.1)

radius = r_on_a0 * data.a0

Rnl = data.Rnl

for n, l in [(3, 0), (2, 1)]:
    figs = {
        'R': lt.ltFigure(name='fig-R{}{}'.format(n, l), width_frac=.25),
        'R2': lt.ltFigure(name='fig-R{}{}_squared'.format(n, l),
                          width_frac=.25),
        'p': lt.ltFigure(name='fig-R{}{}_proba'.format(n, l), width_frac=.25),
    }
    x = r_on_a0
    ys = {
        'R': Rnl(radius, n, l),
        'R2': Rnl(radius, n, l)**2,
        'p': 4 * np.pi * (radius)**2 * Rnl(radius, n, l)**2,
    }
    for subkey, fig in figs.items():
        fig.addgraph('graph1',
                     x_min=0,
                     x_max=data.r_on_a0_max['{}x'.format(n)],
                     y_ticks=False,
                     show_x_axis=True)
        if subkey != 'R' or n == l + 1:
            fig.graphs['graph1'].y_min = 0
            fig.graphs['graph1'].y_max = 1
        fig.addplot(lt.ltPlotFct(x, ys[subkey] / max(ys[subkey])), 'graph1')
        fig.save(format='pdf')
Exemplo n.º 6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

import ltLaTeXpyplot as lt

# Create figure
fig = lt.ltFigure(name='fig')

# Define what to plot
k = np.arange(1e5)
x = np.sin(2*np.pi*k*k/k.max()*k/k.max()/10)+.5*np.sin(2*np.pi*k/5)

fct = lt.ltPlotFct(k, x, Nfft = 1024)

# Define graphs
fig.addgraph('graph3', x_label='time', y_label='$f$ (Hz)')

# Insérer les objets à tracer dans le plot
fct.plot_TFrp(fig, 'graph3')

# Sauvegarder la figure
fig.save(format='pdf')
Exemplo n.º 7
0
# example error bar values that vary with x-position
error = 0.1 + 0.2 * x

# Define graphs
fig.addgraph('graph1',
             position=211,
             title='variable, symmetric error',
             x_ticks=False)
fig.addgraph('graph2',
             position=212,
             title='variable, asymmetric error',
             share_x='graph1',
             y_scaling='log',
             num_y_major=False)

# Insert object in plots
pts1 = lt.ltPlotPts(x, y, yerr=error, marker='o')
fct1 = lt.ltPlotFct(x, y)
pts1.plot(fig, 'graph1')
fct1.plot(fig, 'graph1')

lower_error = 0.4 * error
upper_error = error
asymmetric_error = [lower_error, upper_error]

fct2 = lt.ltPlotPts(x, y, xerr=asymmetric_error, marker='o')
fct2.plot(fig, 'graph2')

# Save figure
fig.save(format='pdf')
Exemplo n.º 8
0
import numpy as np

import ltLaTeXpyplot as lt

# Create figure
fig = lt.ltFigure(name='fig')

# Define what to plot
tau = 10.
f0 = 1.
omega0 = 2 * np.pi * f0
t = np.arange(0., 50., 0.01)
x = np.sin(omega0 * t) * np.exp(-t / tau)

fct = lt.ltPlotFct(t, x, Fs=1 / t[1])

# Define graphs
fig.addgraph('graph1',
             x_label='$\\nu$ (Hz)',
             y_label='TF',
             show_legend=True,
             legend_on_side=False,
             x_min=0,
             x_max=2)

# Insert object in plots
fct.plot_TF(fig, 'graph1', label='Fourier tr.')

# Save figure
fig.save(format='pdf')