Difference between revisions of "Plot 2d.m"

From Spinach Documentation Wiki
Jump to: navigation, search
(Created page with "Contour plotting utility with non-linear adaptive contour spacing. The function is useful for NMR data where small cross-peaks must be adequa- tely contoured next to large dia...")
 
(removed link to deleted function page bloch_sph_plot.m (removed per IK instruction 2026-08-30))
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
−
Contour plotting utility with non-linear adaptive contour spacing. The
+
{{DISPLAYTITLE:plot_2d.m}} __NOTOC__
−
function is useful for NMR data where small cross-peaks must be adequa-
+
Contour plotting utility with non-linear adaptive contour spacing. The function is useful for NMR data where small cross-peaks must be adequately contoured next to large diagonal peaks.
−
tely contoured next to large diagonal peaks. Syntax:
 
  
−
  plot_2d(spin_system,spectrum,parameters,ncont,delta,k,ncol,m,signs)
+
==Syntax==
  
−
The following functions are used to compute contour levels:
 
  
−
  cont_levs_pos=delta(2)*xmax*linspace(0,1,ncont).^k+xmax*delta(1);
+
    [axis_f1,axis_f2,spectrum]=plot_2d(spin_system,spectrum,...
−
  cont_levs_neg=delta(2)*xmin*linspace(0,1,ncont).^k+xmin*delta(1);
+
                                                parameters,ncont,delta,...
 +
                                                k,ncol,m,signs)
  
−
where:
+
==Parameters==
  
−
     * xmax and xmin are calculated from the spectrum;
+
    spectrum - a real matrix containing the 2D NMR spectrum
 +
 +
    parameters.sweep      -  one or two sweep widths, Hz
 +
 +
    parameters.spins      -  cell array with one ot two character
 +
                              strings specifying the working spins
 +
 +
    parameters.offset      -  one or two transmitter offsets, Hz
 +
 +
    parameters.axis_units  -  axis units ('ppm','Hz','Gauss')
 +
 +
    ncont     - the number of contours, a reasonable value is 20
 +
 +
    delta    - minimum and maximum elevation (as a fraction of the
 +
                total intensity) of the contours above the baseline.
 +
                A good starting value is [0.02 0.2 0.02 0.2]. The
 +
                first pair of numbers refers to the positive conto-
 +
                urs and the second pair to the negative ones.
 +
 +
    k    - a coefficient that controls the curvature of the contour
 +
            spacing function: k=1 corresponds to linear spacing and
 +
            k>1 bends the spacing curve to increase the sampling den-
 +
            sity near the baseline. A reasonable value is 2.
 +
 +
    ncol - number of colours in the colour map; around 256 is fine
 +
 +
    m    - the curvature of the colour map: m=1 corresponds to a li-
 +
            near colour ramp into the red for positive contours, and
 +
            into the blue for negative contours. A reasonable value
 +
            for high-contrast plotting is 6.
 +
 +
    signs  - can be set to 'positive', 'negative' or 'both' - this
 +
              will cause the corresponding contours to be plotted.
  
−
    * delta is the minimum and maximum elevation (as a fraction of total
+
==Outputs==
−
      intensity) of the contours above the baseline. A reasonable value
 
−
      for most 2D spectra is [0.02 0.2 0.02 0.2]. The first pair of num-
 
−
      bers refers to the positive contours and the second pair to the
 
−
      negative ones.
 
−
     
 
−
    * ncont is the number of contours, a reasonable value is 20.
 
  
−
    * k controls the curvature of the contour spacing function: k=1
+
    a figure is drawn and the following parameters are returned
−
      corresponds to linear spacing and k>1 bends the spacing curve to
+
−
      increase the sampling density near the baseline. A reasonable
+
    axis_f1, axis_f2 - F1 and F2 axis ticks for external
−
      value is 2;
+
                        plotting utilities
 +
 +
    spectrum        - 2D spectrum array for external
 +
                        plotting utilities
  
−
    * ncol is a number of colors in the colormap (around 256 is fine);
+
==Examples==
 +
Below is the output of examples/esr_solids/hyscore_nitroxide_powder.m example file.
  
−
    * m is the curvature of the colormap: m=1 corresponds to a linear
+
[[File:hyscore_nitroxide_powder.png]]
−
      color ramp into the red for positive contours and into the blue
 
−
      for negative contours. A reasonable value for high-contrast
 
−
      plotting is 6.
 
  
−
    * signs can be set to 'positive', 'negative' or 'both' - this will
+
==Notes==
−
      cause the corresponding contours to be plotted.
+
The following functions are used to compute contour levels:
−
 
 
−
The following subfields are required inthe parameters structure:
 
  
−
    parameters.sweep              one or two sweep widths, Hz
+
  cont_levs_pos=delta(2)*smax*linspace(0,1,ncont).^k+smax*delta(1);
 +
  cont_levs_neg=delta(2)*smin*linspace(0,1,ncont).^k+smin*delta(1);
  
−
    parameters.spins              cell array with one ot two character
+
where smin and smax are computed from the spectrum matrix.
−
                                  strings specifying the working spins.
 
  
−
    parameters.offset            one or two transmitter offsets, Hz
+
==See also==
 +
[[plot_1d.m]], [[plot_3d.m]], [[volplot.m]], [[molplot.m]], [[mri_2d_plot.m]], [[slice_2d.m]], [[int_2d.m]], [[hfc_display.m]], [[cst_display.m]], [[apodisation.m]], [[axis_1d.m]], [[bwr_cmap.m]], [[contspacing.m]], [[crop_2d.m]], [[cylgrid.m]], [[fid2ascii.m]], [[ft_axis.m]], [[heterodyne.m]], [[plot_uf.m]], [[s2json.m]], [[scale_figure.m]], [[stack_2d.m]], [[sweep2ticks.m]], [[write_movie.m]], [[xyz2pd.m]], [[zoom_3d.m]], [[Import,_export,_and_visualisation]], [[Kernel_utilities]]
  
−
    parameters.axis_units        axis units ('ppm','Hz','Gauss')
+
''Version 2.3, authors: [[Ilya Kuprov]]''

Latest revision as of 10:10, 30 August 2026

Contour plotting utility with non-linear adaptive contour spacing. The function is useful for NMR data where small cross-peaks must be adequately contoured next to large diagonal peaks.

Syntax

    [axis_f1,axis_f2,spectrum]=plot_2d(spin_system,spectrum,...
                                               parameters,ncont,delta,...
                                               k,ncol,m,signs)

Parameters

    spectrum - a real matrix containing the 2D NMR spectrum

    parameters.sweep       -  one or two sweep widths, Hz

    parameters.spins       -  cell array with one ot two character
                              strings specifying the working spins

    parameters.offset      -  one or two transmitter offsets, Hz

    parameters.axis_units  -  axis units ('ppm','Hz','Gauss')

    ncont     - the number of contours, a reasonable value is 20

    delta     - minimum and maximum elevation (as a fraction of the
                total intensity) of the contours above the baseline.
                A good starting value is [0.02 0.2 0.02 0.2]. The
                first pair of numbers refers to the positive conto-
                urs and the second pair to the negative ones.

    k    - a coefficient that controls the curvature of the contour
           spacing function: k=1 corresponds to linear spacing and
           k>1 bends the spacing curve to increase the sampling den-
           sity near the baseline. A reasonable value is 2.

    ncol - number of colours in the colour map; around 256 is fine

    m    - the curvature of the colour map: m=1 corresponds to a li-
           near colour ramp into the red for positive contours, and
           into the blue for negative contours. A reasonable value
           for high-contrast plotting is 6.

    signs   - can be set to 'positive', 'negative' or 'both' - this
              will cause the corresponding contours to be plotted.

Outputs

    a figure is drawn and the following parameters are returned

    axis_f1, axis_f2 - F1 and F2 axis ticks for external
                        plotting utilities

    spectrum         - 2D spectrum array for external
                        plotting utilities

Examples

Below is the output of examples/esr_solids/hyscore_nitroxide_powder.m example file.

Hyscore nitroxide powder.png

Notes

The following functions are used to compute contour levels:

 cont_levs_pos=delta(2)*smax*linspace(0,1,ncont).^k+smax*delta(1);
 cont_levs_neg=delta(2)*smin*linspace(0,1,ncont).^k+smin*delta(1);

where smin and smax are computed from the spectrum matrix.

See also

plot_1d.m, plot_3d.m, volplot.m, molplot.m, mri_2d_plot.m, slice_2d.m, int_2d.m, hfc_display.m, cst_display.m, apodisation.m, axis_1d.m, bwr_cmap.m, contspacing.m, crop_2d.m, cylgrid.m, fid2ascii.m, ft_axis.m, heterodyne.m, plot_uf.m, s2json.m, scale_figure.m, stack_2d.m, sweep2ticks.m, write_movie.m, xyz2pd.m, zoom_3d.m, Import,_export,_and_visualisation, Kernel_utilities

Version 2.3, authors: Ilya Kuprov