tmd.view.common¶
Module containing the common functionality to be used by view-plot modules.
Functions
|
Helping function to define the strings that handle pre-post conventions. |
|
If treecolor is none returns the color depending on the type. |
|
Function to be used for viewing - plotting, to initialize the matplotlib figure - axes. |
|
Plots the gaussian kernel of the input image. |
|
Function that defines the labels options of a matplotlib plot. |
|
Function that defines the legend options of a matplotlib plot. |
|
Function that defines the limit options of a matplotlib plot. |
|
Plots a 3d sphere, given the center and the radius. |
|
Function to set the basic options of a matplotlib figure. |
|
Function that defines the labels options of a matplotlib plot. |
|
Function that defines the title options of a matplotlib plot. |
|
Function to be used for viewing - plotting to save a matplotlib figure. |
- tmd.view.common.figure_naming(pretitle=None, posttitle=None, prefile=None, postfile=None)¶
Helping function to define the strings that handle pre-post conventions.
These strings can be used for viewing - plotting title and saving options.
- Parameters:
pretitle – str String to include before the general title of the figure. Default is None.
posttitle – str String to include after the general title of the figure. Default is None.
prefile – str String to include before the general filename of the figure. Default is None.
postfile – str String to include after the general filename of the figure. Default is None.
- Returns:
- string
String to include in the figure name and title, in a suitable form.
- Return type:
string_output
- tmd.view.common.get_color(treecolor, tree_type)¶
If treecolor is none returns the color depending on the type.
The mapping is the following: * Basal dendrite: “red” * Axon : “blue” * Apical dendrite: “purple” * Soma tree: “black” * Undefined-Any other unrecognised type: “green”
Otherwise return the treecolor.
- tmd.view.common.get_figure(new_fig=True, new_axes=False, subplot=False, params=None, no_axes=False)¶
Function to be used for viewing - plotting, to initialize the matplotlib figure - axes.
- Parameters:
new_fig – boolean Defines if a new figure will be created. If False the current figure is returned. Default is True.
subplot – subplot or False Defines if a subplot will be generated. If False the subplot is the standard 111. Default is False.
params – dict If dict not empty the parameters will be passed to the initialization of the axes. Default value is {}
no_axes – boolean Defines the output of the function: If False the axes is returned. If True the figure is returned. Default value is False.
- Returns:
- figure or axes
Returns a figure if no_axes is True, or axes if no_axes is False.
- tmd.view.common.plot_img_basic(img, new_fig=True, subplot=111, title='', xlim=None, ylim=None, colorbar=False, cmap=<matplotlib.colors.LinearSegmentedColormap object>, vmin=None, vmax=None, masked=False, threshold=0.01, **kwargs)¶
Plots the gaussian kernel of the input image.
- tmd.view.common.plot_labels(fig, ax, **kwargs)¶
Function that defines the labels options of a matplotlib plot.
- Args
fig: matplotlib figure
ax: matplotlib axes
- Keyword Arguments:
xlabel – str The xlabel for the figure. For no_xlabel set to ‘’. Default value is “X”.
ylabel – str The xlabel for the figure. For no_ylabel set to ‘’. Default value is “Y”.
zlabel – str The zlabel for the figure. For no_zlabel set to ‘’. Default value is “Z”.
label_fontsize – int Defines the size of the labels’ font. Default value is 14.
xlabel_arg – dict Defines the arguments that will be passed into matplotlib as xlabel arguments. Default value is None.
ylabel_arg – dict Defines the arguments that will be passed into matplotlib as ylabel arguments. Default value is None.
zlabel_arg – dict Defines the arguments that will be passed into matplotlib as zlabel arguments. Default value is None.
- Returns:
figure, axes
- Return type:
figure_output
- tmd.view.common.plot_legend(fig, ax, **kwargs)¶
Function that defines the legend options of a matplotlib plot.
- Parameters:
fig – matplotlib figure
ax – matplotlib axes
- Keyword Arguments:
no_legend – boolean Defines the presence of a legend in the figure. If True the legend will not be included in the Figure. Default value is True.
legend_arg – dict Defines the arguments that will be passed into matplotlib as legend arguments. Default value is None.
- Returns:
figure, axes
- Return type:
figure_output
- tmd.view.common.plot_limits(fig, ax, **kwargs)¶
Function that defines the limit options of a matplotlib plot.
- Parameters:
fig – matplotlib figure
ax – matplotlib axes
- Keyword Arguments:
no_limits – boolean Defines the presence of plot limits in the figure. Default value is False.
no_xlim – boolean Defines the presence of plot x-limits in the figure. Default value is False.
no_ylim – boolean Defines the presence of plot y-limits in the figure. Default value is False.
xlim – list of two floats Defines the min and the max values in x-axis. Default in None
ylim – list of two floats Defines the min and the max values in y-axis. Default in None
- Returns:
figure, axes
- Return type:
figure_output
- tmd.view.common.plot_sphere(fig, ax, center, radius, color='black', alpha=1.0)¶
Plots a 3d sphere, given the center and the radius.
- tmd.view.common.plot_style(fig, ax, **kwargs)¶
Function to set the basic options of a matplotlib figure.
- Parameters:
ax – matplotlib axes
- Keyword Arguments:
pretitle – str String to include before the general title of the figure. Default value is None.
posttitle – str String to include after the general title of the figure. Default value is None.
title – str The title for the figure Default value is “Figure”.
no_title – boolean Defines the presence of a title in the figure. If True the title will be set to an empty string “”. Default value is False.
title_fontsize – int Defines the size of the title’s font. Default value is 14.
title_arg – dict Defines the arguments that will be passed into matplotlib as title arguments. Default value is None.
xlabel – str The xlabel for the figure Default value is “X”.
ylabel – str The xlabel for the figure Default value is “Y”.
no_labels – boolean Defines the presence of the labels in the figure. If True the labels will be set to an empty string “”. Default value is False.
no_xlabel – boolean Defines the presence of the xlabel in the figure. If True the xlabel will be set to an empty string “”. Default value is False.
no_ylabel – boolean Defines the presence of the ylabel in the figure. If True the ylabel will be set to an empty string “”. Default value is False.
label_fontsize – int Defines the size of the labels’ font. Default value is 14.
xlabel_arg – dict Defines the arguments that will be passed into matplotlib as xlabel arguments. Default value is None.
ylabel_arg – dict Defines the arguments that will be passed into matplotlib as ylabel arguments. Default value is None.
no_ticks – boolean Defines the presence of x-y ticks in the figure. If True the ticks will be empty. Default value is False.
no_xticks – boolean Defines the presence of x ticks in the figure. If True the ticks will be empty. Default value is False.
no_yticks – boolean Defines the presence of y ticks in the figure. If True the ticks will be empty. Default value is False.
xticks – list of ticks Defines the values of x ticks in the figure. Default value is None.
yticks – list of ticks Defines the values of y ticks in the figure. Default value is None.
tick_fontsize – int Defines the size of the ticks’ font. Default value is 12.
xticks_arg – dict Defines the arguments that will be passed into matplotlib as xticks arguments. Default value is None.
yticks_arg – dict Defines the arguments that will be passed into matplotlib as yticks arguments. Default value is None.
no_limits – boolean Defines the presence of plot limits in the figure. Default value is False.
no_xlim – boolean Defines the presence of plot x-limits in the figure. Default value is False.
no_ylim – boolean Defines the presence of plot y-limits in the figure. Default value is False.
xlim – list of two floats Defines the min and the max values in x-axis. Default in None
ylim – list of two floats Defines the min and the max values in y-axis. Default in None
no_legend – boolean Defines the presence of a legend in the figure. If True the legend will not be included in the Figure. Default value is True.
legend_arg – dict Defines the arguments that will be passed into matplotlib as legend arguments. Default value is None.
prefile – str String to include before the general filename of the figure. Default is None.
postfile – str String to include after the general filename of the figure. Default is None.
output_path – str String to define the path to the output directory. Default value is ‘./’
output_name – str String to define the name of the output figure. Default value is ‘Figure’
output_format – str String to define the format of the output figure. Default value is ‘png’
dpi – int Define the DPI (Dots per Inch) of the figure. Default value is 300.
transparent – boolean If True the saved figure will have a transparent background. Default value is False.
show_plot – boolean If True the figure is displayed. Default value is True.
no_axes – boolean If True the labels and the frame will be set off. Default value is False.
tight – boolean If True the set layout of matplotlib will be activated. Default value is False.
- Returns:
figure, axes
- Return type:
figure_output
- tmd.view.common.plot_ticks(fig, ax, **kwargs)¶
Function that defines the labels options of a matplotlib plot.
- Args
fig: matplotlib figure
ax: matplotlib axes
- Keyword Arguments:
xticks – list of ticks Defines the values of x ticks in the figure. If None the xticks will not be modified. For no_xticks set to []. Default value is None.
yticks – list of ticks Defines the values of y ticks in the figure. If None the yticks will not be modified. For no_yticks set to []. Default value is None.
zticks – list of ticks Defines the values of z ticks in the figure. If None the zticks will not be modified. For no_zticks set to []. Default value is None.
tick_fontsize – int Defines the size of the ticks’ font. Default value is 12.
xticks_arg – dict Defines the arguments that will be passed into matplotlib as xticks arguments. Default value is None.
yticks_arg – dict Defines the arguments that will be passed into matplotlib as yticks arguments. Default value is None.
zticks_arg – dict Defines the arguments that will be passed into matplotlib as zticks arguments. Default value is None.
- Returns:
figure, axes
- Return type:
figure_output
- tmd.view.common.plot_title(fig, ax, **kwargs)¶
Function that defines the title options of a matplotlib plot.
- Parameters:
fig – matplotlib figure
ax – matplotlib axes
- Keyword Arguments:
pretitle – str String to include before the general title of the figure. Default value is None.
posttitle – str String to include after the general title of the figure. Default value is None.
title – str Set the title for the figure. If “” no title will be added. Default value is “Figure”.
title_fontsize – int Defines the size of the title’s font. Default value is 14.
title_arg – dict Defines the arguments that will be passed into matplotlib as title arguments. Default value is None.
- Returns:
figure, axes
- Return type:
figure_output
- tmd.view.common.save_plot(fig, **kwargs)¶
Function to be used for viewing - plotting to save a matplotlib figure.
- Parameters:
fig – matplotlib figure
- Keyword Arguments:
prefile – str String to include before the general filename of the figure. Default is None.
postfile – str String to include after the general filename of the figure. Default is None.
output_path – str String to define the path to the output directory. Default value is ‘./’
output_name – str String to define the name of the output figure. Default value is ‘Figure’
output_format – str String to define the format of the output figure. Default value is ‘png’
dpi – int Define the DPI (Dots per Inch) of the figure. Default value is 300.
transparent – boolean If True the saved figure will have a transparent background. Default value is False.
- Returns:
Generates a figure file in the selected directory.