示例#1
0
def save_fifi(layout: FigureLayout, name: str) -> None:
    """Finalize fifi figure and save.

    Insert figure to panels layer and add enable the annotation layer.
    Save and close the figure.

    :param layout: Figurefirst layout
    :param name: Name of the figure
    :return: None
    """
    layout.insert_figures('panels', cleartarget=True)
    layout.set_layer_visibility('annotation', True)
    layout.write_svg(FIGURE_PATH / f'{name}.svg')
    plt.close('all')
示例#2
0
import numpy as np
from figurefirst import FigureLayout

layout = FigureLayout('example_jessyink_layout.svg')
layout.make_mplfigures()

x_data = np.arange(30)

ax = layout.axes['ax_name']['axis']
ax.plot(x_data, x_data**3, color='k', gid='figurefirst:line1')
ax.fill_between(x_data, .5*x_data**3, 2*x_data**3, color='k', edgecolor='none', alpha=.3, gid='figurefirst:fill1')
ax.plot(x_data, x_data[::-1]**3, color='r', gid='figurefirst:line2')
ax.axvspan(2, 10, color='b', alpha=.2, gid='figurefirst:span1')

layout.apply_mpl_methods()
layout.insert_figures('figurefirst_target_layer')

layout.pass_xml('figurefirst:span1','jessyink:effectIn', 'name:appear;order:1;length:800')
layout.pass_xml('figurefirst:line1','jessyink:effectIn', 'name:appear;order:2;length:800')
layout.pass_xml('figurefirst:fill1','jessyink:effectIn', 'name:appear;order:2;length:800')
layout.pass_xml('figurefirst:line2','jessyink:effectIn', 'name:appear;order:3;length:800')

layout.write_svg('example_jessyink_output.svg')

from pylab import *
from figurefirst import FigureLayout, mpl_functions

# You can decorate the svg <figurefirsrt:axis> tag with mpl.axis methods. For example to call ax.axhspan(100,200,zorder=10,color ='r',alpha = 0.3) on the axis named frequency.22H05.start use the following tag:
#
# ```
# <figurefirst:axis
#      figurefirst:name="frequency.22H05.start"
#      figurefirst:axhspan="100,200,zorder=10,color='r',alpha=.3"/> ```
#
# The layout.apply_mpl_methods function will then apply the methods passing the value of the svg atribute as arguments to the mpl.axis method.

#Passing axis methods
import numpy as np
layout = FigureLayout('example_axis_methods_layout.svg')
layout.make_mplfigures()
layout.fig.set_facecolor('None')
for mplax in layout.axes.values():
    ax = mplax['axis']
    ax.plot(np.arange(30), np.random.rand(30), color='k')
    mpl_functions.adjust_spines(ax,
                                'none',
                                spine_locations={},
                                smart_bounds=True,
                                xticks=None,
                                yticks=None,
                                linewidth=1)
    ax.patch.set_facecolor('None')
layout.apply_mpl_methods()
layout.insert_figures('mpl_panel_a')
layout.write_svg('example_axis_methods_output.svg')
#!/usr/bin/env python
from pylab import *
from figurefirst import FigureLayout,mpl_functions

#Group axes example
layout = FigureLayout('example_group_axes_layout.svg')
layout.make_mplfigures()
layout.insert_figures()
layout.write_svg('example_group_axes_output.svg')
close('all')
示例#5
0
from pylab import *
from figurefirst import FigureLayout, mpl_functions

print('running multi figure example')
#Groups and figures example
layout = FigureLayout('example_multi_fig_layout.svg')
mplfig = layout.make_mplfigures()
layout.append_figure_to_layer(layout.figures['threeport'], 'mpl_layer_2')
layout.append_figure_to_layer(layout.figures['oval'], 'mpl_layer_3')
layout.append_figure_to_layer(layout.figures['holy'], 'mpl_layer_4')
layout.write_svg('example_multi_fig_output.svg')
close('all')
示例#6
0
#!/usr/bin/env python
import numpy as np
from figurefirst import FigureLayout

layout = FigureLayout('example_jessyink_layout.svg')
layout.make_mplfigures()

x_data = np.arange(30)

ax = layout.axes['ax_name']['axis']
ax.plot(x_data, x_data**3, color='k', gid='figurefirst:line1')
ax.fill_between(x_data, .5*x_data**3, 2*x_data**3, color='k', edgecolor='none', alpha=.3, gid='figurefirst:fill1')
ax.plot(x_data, x_data[::-1]**3, color='r', gid='figurefirst:line2')
ax.axvspan(2, 10, color='b', alpha=.2, gid='figurefirst:span1')

layout.apply_mpl_methods()
layout.insert_figures('figurefirst_target_layer')

layout.pass_xml('figurefirst:span1','jessyink:effectIn', 'name:appear;order:1;length:800')
layout.pass_xml('figurefirst:line1','jessyink:effectIn', 'name:appear;order:2;length:800')
layout.pass_xml('figurefirst:fill1','jessyink:effectIn', 'name:appear;order:2;length:800')
layout.pass_xml('figurefirst:line2','jessyink:effectIn', 'name:appear;order:3;length:800')

layout.write_svg('example_jessyink_output.svg')

import numpy as np
import matplotlib.pyplot as plt
plt.ion()
from figurefirst import FigureLayout

layout = FigureLayout('example_hello_world_layout.svg')
layout.make_mplfigures()

d = np.array([[144, 57], [138, 57], [138, 59], [141, 61], [141, 82], [138, 84],
              [138, 85], [142, 85], [147, 85], [147, 84], [144, 82], [144, 57],
              [144, 57], [155, 57], [149, 57], [149, 59], [152, 61], [152, 82],
              [149, 84], [149, 85], [153, 85], [158, 85], [158, 84], [155, 82],
              [155, 57], [155, 57], [273, 57], [267, 57], [267, 59], [270, 61],
              [270, 82], [267, 84], [267, 85], [271, 85], [276, 85], [276, 84],
              [273, 82], [273, 57], [273, 57], [295, 57], [289, 57], [289, 59],
              [292, 61], [292, 70], [287, 67], [278, 76], [287, 85], [292, 83],
              [292, 85], [298, 85], [298, 84], [295, 81], [295, 57], [295, 57],
              [90, 57], [90, 59], [91, 59], [94, 61], [94, 82], [91, 84],
              [90, 84], [90, 85], [96, 85], [102, 85], [102, 84], [101, 84],
              [98, 82], [98, 71], [110, 71], [110, 82], [107, 84], [106, 84],
              [106, 85], [112, 85], [118, 85], [118, 84], [117, 84], [113, 82],
              [113, 61], [117, 59], [118, 59], [118, 57], [112, 58], [106, 57],
              [106, 59], [107, 59], [110, 61], [110, 70], [98, 70], [98, 61],
              [101, 59], [102, 59], [102, 57], [96, 58], [90, 57], [90, 57],
              [193, 57], [193, 59], [197, 60], [205, 85], [205, 86], [206, 85],
              [213, 65], [219, 85], [220, 86], [221, 85], [229, 61], [233, 59],
              [233, 57], [229, 58], [224, 57], [224, 59], [228, 61], [227, 62],
              [221, 80], [215, 60], [215, 60], [218, 59], [218, 57], [213, 58],
              [208, 57], [208, 59], [211, 60], [212, 63], [207, 80], [200, 60],
              [200, 60], [203, 59], [203, 57], [198, 58], [193, 57], [193, 57],
              [128, 67], [120, 76], [129, 85], [135, 80], [135, 80], [134, 80],
示例#8
0
import numpy as np
import matplotlib.pyplot as plt
from figurefirst import FigureLayout

layout = FigureLayout('bubbles.svg')
layout.make_mplfigures()
ax = layout.axes['axis_name']['axis']
data = np.genfromtxt('RANGE_3D_H_200_05_c.txt', skip_header=18)
x = data[:, 1]
mean = np.mean(x)
std = np.std(x)
num_bins = 50
bins = np.linspace(mean - 6. * std, mean + 6. * std, num_bins)
values, bins = np.histogram(x, bins=bins, density=True)
centers = bins[:-1] + (bins[1:] - bins[:-1]) / 2.
ax.plot(centers, values, linewidth=1, color='black')
ax.fill_between(centers, values, alpha=0.25, color='black')
ax.axis('off')
ax.set_xticks([])
ax.set_yticks([])
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
layout.insert_figures('target_layer_name')
layout.write_svg('bubbles.svg')
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
from figurefirst import FigureLayout

layout = FigureLayout('example_hello_world_layout.svg')
layout.make_mplfigures()

d = np.array([[144, 57], [138, 57], [138, 59], [141, 61], [141, 82], [138, 84], [138, 85], [142, 85], [147, 85], [147, 84], [144, 82], [144, 57], [144, 57], [155, 57], [149, 57], [149, 59], [152, 61], [152, 82], [149, 84], [149, 85], [153, 85], [158, 85], [158, 84], [155, 82], [155, 57], [155, 57], [273, 57], [267, 57], [267, 59], [270, 61], [270, 82], [267, 84], [267, 85], [271, 85], [276, 85], [276, 84], [273, 82], [273, 57], [273, 57], [295, 57], [289, 57], [289, 59], [292, 61], [292, 70], [287, 67], [278, 76], [287, 85], [292, 83], [292, 85], [298, 85], [298, 84], [295, 81], [295, 57], [295, 57], [90, 57], [90, 59], [91, 59], [94, 61], [94, 82], [91, 84], [90, 84], [90, 85], [96, 85], [102, 85], [102, 84], [101, 84], [98, 82], [98, 71], [110, 71], [110, 82], [107, 84], [106, 84], [106, 85], [112, 85], [118, 85], [118, 84], [117, 84], [113, 82], [113, 61], [117, 59], [118, 59], [118, 57], [112, 58], [106, 57], [106, 59], [107, 59], [110, 61], [110, 70], [98, 70], [98, 61], [101, 59], [102, 59], [102, 57], [96, 58], [90, 57], [90, 57], [193, 57], [193, 59], [197, 60], [205, 85], [205, 86], [206, 85], [213, 65], [219, 85], [220, 86], [221, 85], [229, 61], [233, 59], [233, 57], [229, 58], [224, 57], [224, 59], [228, 61], [227, 62], [221, 80], [215, 60], [215, 60], [218, 59], [218, 57], [213, 58], [208, 57], [208, 59], [211, 60], [212, 63], [207, 80], [200, 60], [200, 60], [203, 59], [203, 57], [198, 58], [193, 57], [193, 57], [128, 67], [120, 76], [129, 85], [135, 80], [135, 80], [134, 80], [129, 84], [125, 82], [123, 76], [134, 76], [135, 75], [128, 67], [128, 67], [169, 67], [160, 76], [169, 85], [178, 76], [169, 67], [169, 67], [240, 67], [231, 76], [240, 85], [249, 76], [240, 67], [240, 67], [257, 67], [251, 68], [251, 69], [254, 71], [254, 82], [251, 84], [251, 85], [256, 85], [261, 85], [261, 84], [260, 84], [257, 82], [257, 75], [262, 68], [262, 68], [261, 70], [263, 71], [265, 70], [262, 67], [257, 71], [257, 67], [257, 67], [128, 68], [133, 75], [123, 75], [128, 68], [128, 68], [169, 68], [173, 70], [174, 76], [173, 81], [169, 84], [164, 82], [163, 76], [164, 70], [169, 68], [169, 68], [240, 68], [244, 70], [246, 76], [245, 81], [240, 84], [235, 82], [234, 76], [235, 70], [240, 68], [240, 68], [287, 68], [292, 70], [292, 72], [292, 80], [292, 82], [287, 84], [283, 82], [281, 76], [283, 71], [287, 68], [287, 68]])

ax = layout.axes['ax_name']['axis']

ax.plot(d[:,0], -d[:,1], lw=4)

layout.insert_figures('target_layer_name')

layout.write_svg('example_hello_world_output.svg')
#!/usr/bin/env python
from pylab import *
from figurefirst import FigureLayout,mpl_functions

# You can decorate the svg <figurefirsrt:axis> tag with mpl.axis methods. For example to call ax.axhspan(100,200,zorder=10,color ='r',alpha = 0.3) on the axis named frequency.22H05.start use the following tag:
# 
# ```
# <figurefirst:axis
#      figurefirst:name="frequency.22H05.start"
#      figurefirst:axhspan="100,200,zorder=10,color='r',alpha=.3"/> ```
#      
# The layout.apply_mpl_methods function will then apply the methods passing the value of the svg atribute as arguments to the mpl.axis method.

#Passing axis methods
import numpy as np
layout = FigureLayout('example_axis_methods_layout.svg')
layout.make_mplfigures()
layout.fig.set_facecolor('None')
for mplax in layout.axes.values():
    ax = mplax['axis']
    ax.plot(np.arange(30),np.random.rand(30),color = 'k')
    mpl_functions.adjust_spines(ax,'none', 
                  spine_locations={}, 
                  smart_bounds=True, 
                  xticks=None, 
                  yticks=None, 
                  linewidth=1)
    ax.patch.set_facecolor('None')
layout.apply_mpl_methods()
layout.insert_figures('mpl_panel_a')
layout.write_svg('example_axis_methods_output.svg')
示例#11
0
#!/usr/bin/env python
from pylab import *
from figurefirst import FigureLayout, mpl_functions

#Group axes example
layout = FigureLayout('example_group_axes_layout.svg')
layout.make_mplfigures()
layout.insert_figures()
layout.write_svg('example_group_axes_output.svg')
close('all')
 def __init__(self):
     self.layout: FigureLayout = FigureLayout(self.layout_path, make_mplfigures=True)