Skip to content

Plot.py

SwoosOfficial edited this page Feb 26, 2018 · 17 revisions

This class is parent to every Plot file of TychePlot. Thus any parameter present will also be applyable to the child scripts.

Constructor:

  • Required Input parameters:

    • name:
      • Type: String
      • The name is used for the filename of the output file (if not given specifically)
    • fileList:
      • Type: List or Tuple
      • Format: [[sample_A_measurement_1_filename,sample_A_measurement_2_filename],[sample_B_measurement_1_filename,sample_B_measurement_2_filename]]
      • The fileList has to be a list or tuple with the raw data filenames.
      • The fileList has to be nested where the elements of fileList are list of datafilenames of the same sample (the average will be calculated based on the sublists).
  • Optional Input parameters:

    • fileFormat:

      • Type: Dictonary
      • Default: {"separator":"\t", "skiplines":1}
      • The fileformat dictionary contains data which will be passed to the Filereader.py script
      • Most frequent Keys: separator, skiplines
    • showColTup:

      • Type: Tuple
      • Default: (2,3)
      • Format: (showColumn_leftAxis,showColumn_rightAxis)
      • This tuple declares which columns of the data should be showed in the Plot.
      • Zero means do not show that axis (only for valid for right axis; left axis is obligatory).
    • xLim:

      • Type: Tuple
      • Default: None
      • Format: (lower_xLimValue,upper_xLimValue)
      • This tuple declares limits for the x Column after data processing (at the end of processData()).
      • abstract only for use in child classes.
    • xLimOrig:

      • Type: Tuple
      • Default: None
      • Format: (lower_xLimValue,upper_xLimValue)
      • This tuple declares limits for the x Column before data processing (at the start of self.processData()).
    • yLim:

      • Type: Tuple
      • Default: None
      • Format: (lower_xLimValue_leftAxis,upper_xLimValue_leftAxis) or ((lower_xLimValue_leftAxis,upper_xLimValue_leftAxis),(lower_xLimValue_rightAxis,upper_xLimValue_rightAxis))
      • This tuple declares limits for the (respective) y-Axes.
    • scaleX:

      • Type: Float
      • Default: 1
      • This value defines the scaling of the figure's size including its linewidths (mostly every rcParam of matplotlib; see _scaleRCParams())
    • customFontsize:

      • Type: Tuple
      • Default: None
      • Format: (generalFontsizeInPt,axesLabelFontsizeInPt,legendFontsizeInPt,xTickFontsizeInPt,yTickFontsizeInPt)
      • This tuple overrides the default fontsizes if not None
    • averageMedian:

      • Type: Boolean
      • Default: False
      • If true the median (numpy.median()) is used to determine the average value of given data; If false the arithmetic mean (numpy.average()) is used.
    • xCol:

      • Type: Integer
      • Default: 1
      • The value saves the column to be used for x-axis. This column is valid after data processing.
    • xCol2:

      • Type: Integer
      • Default: 0
      • If 0 no second x-axis will be generated.
      • The value saves the column to be used for a second x-axis at the top. This column is valid after data processing.
    • xColOrig:

      • Type: Integer
      • Default: 1
      • The value saves the column to be used for the x column. This column is only valid before data processing. It is used for calculations within processData() (by child classes).
    • title:

      • Type: String
      • Default: None
      • The value saves a title which will be displayed on top of the Plot.
    • HWratio:

      • Type: Float
      • Default: 0.75
      • The value saves the height to width ratio of the figure. Per default a 4:3 width to height ratio is used so 3/4=0.75
    • fig_width_pt:

      • Type: Float
      • Default: 448.13095
      • The value saves the width of the figure. Default is the pdfLatex textwidth of a document type scrartcl with option a4paper
      • The heigth will be calculated based on the width and the HWratio
    • titleBool:

      • Type: Boolean
      • Default: True
      • If true title will be shown above the Plot, else not.
    • legendEdgeSize:

      • Type: Float
      • Default: 1
      • This value keeps the linewidth of the legends bordering line.
    • ax2Labels:

      • Type: Boolean
      • Default: True
      • If False the the data of the right y axis will not be indicated in the legend.
    • showColAxType:

      • Type: Tuple
      • Default: [None,"lin","lin","lin"]
      • Format: (None,col1AxType,col2AxType,col3AxType)
      • Each element keeps the type of the scale on the for the respective column. This value will be used for matplotlib.pyplot's set_xscale() or set_yscale() to set the scale for each respective column.
      • Note: the 0th element has no use, since there is no 0th column
    • xAxisLim:

      • Type: Tuple
      • Default: None
      • Format: (lower_xLimValue,upper_xLimValue)
      • The value is for cutting the bottom x-axis.
    • showColAxLim:

      • Type: Tuple
      • Default: [None,None,None,None]
      • Format: (None,(lower_col1LimValue,upper_col1LimValue),(lower_col2LimValue,upper_col2LimValue),(lower_col3LimValue,upper_col3LimValue))
      • Note: the 0th element has no use, since there is no 0th column
    • colors:

      • Type: Tuple
      • Default: ['#1f77b4','#d62728','#2ca02c','#9467bd','#8c564b','#e377c2','#7f7f7f','#ff7f0e','#bcbd22','#17becf','#f8e520']
      • A tuple of hexadecimal rgb colors
      • The tuple has to be longer than or as long as the dataList, or there will be an IndexError.
    • showColLabel:

      • Type: Tuple
      • Default: None
      • Format: (None,descriptionOfCol1WithoutUnits,descriptionOfCol2WithoutUnits,descriptionOfCol3WithoutUnits)
      • A tuple of Strings for description of each column. Will be used to build the legend.
      • If None the showColLabelUnit will be used.
      • Note: the 0th element has no use, since there is no 0th column.
    • showColLabelUnit:

      • Type: Tuple
      • Default: ["","X","Y","Y2"]
      • Format: (None,descriptionOfCol1WithUnits,descriptionOfCol2WithUnits,descriptionOfCol3WithUnits)
      • A tuple of Strings for description of each column. Will be used to build the legend.
      • Note: the 0th element has no use, since there is no 0th column.
    • fill:

      • Type: String
      • Default: "_"
      • This string is used to seperate words in e.g. the output filename
    • show:

      • Type: Tuple
      • Default: None
      • Format: ((showSample1showCol1Boolean,showSample1showCol2Boolean),(showSample2showCol1Boolean,showSample2showCol2Boolean))
      • A tuple used for omitting specific graphs on respective axes.
      • If None it will be autogenerated with __initFileList()
    • filename:

      • Type: String
      • Default: None
      • String for specifically give the output filename, to be used in processFileName()
      • If None it will be autogenerated with processFileName()
    • labels:

      • Type: Tuple
      • Default: None
      • Format: (sample1Label,sample2Label)
      • Set the label of the samples to be used in e.g. the legend.
      • If None it will be autogenerated with __initFileList()
    • colorOffset:

      • Type: Integer
      • Default: 0
      • To use another color on the second y axis set this value to another value.
      • For multiple graphs on the same axis its better to use a negative value (with a sufficiently big colors tuple), since the color is chosen via colors[coloroffset]
    • errors:

      • Type: Tuple
      • Default: None
      • Format: ((showSample1ErrorsShowCol1Boolean,showSample1ErrorsShowCol2Boolean),(showSample2ErrorsShowCol1Boolean,showSample2ErrorsShowCol2Boolean))
      • A tuple used for omitting specific errorbars on graphs on respective axes.
      • If None it will be autogenerated with __initFileList()
    • showErrorOnlyEvery:

      • Type: Integer
      • Default: 1
      • Allowed values: 1-?
      • To omit some calculated errors, shows only every x th error, where x is this value.
    • erroralpha:

      • Type: Float
      • Default: 0.5
      • Allowed values: 0-1
      • Set the transparency of the error caps for the left y-axis to transparent (0) or non transparent (1)
    • ax2erroralpha:

      • Type: Float
      • Default: 0.5
      • Allowed values: 0-1
      • Set the transparency of the error caps for the right y-axis to transparent (0) or non transparent (1)
    • erroralphabar:

      • Type: Float
      • Default: 0.5
      • Allowed values: 0-1
      • Set the transparency of the error bars for the left y-axis to transparent (0) or non transparent (1)
    • ax2erroralphabar:

      • Type: Float
      • Default: 0.5
      • Allowed values: 0-1
      • Set the transparency of the error bars for the right y-axis to transparent (0) or non transparent (1)
    • capsize:

      • Type: Float
      • Default: 2
      • Set the width of the cap
    • capthick:

      • Type: Float
      • Default: 1
      • Set the thickness of the cap in pt

Clone this wiki locally