Table Of Contents

Previous topic

Statistics Registers

Next topic

Utility Routines

This Page

Plotting on a console

Make charts on a text console using character graphics

Generate graphical output on a text console. These routines predate modern GUI environments. While the output may look rough, they work just about anywhere.

Here is how the code may be called:

>>> fn = toolbox.GetTest1DataFilename('.smr')
>>> x, y, dy = toolbox.GetDat(fn)
>>> print("Data plot: " + fn)
>>> Screen().xyplot(x, y)

Example, given C(q) and S(q):

KratkyPlot = textplots.Screen()
title = "\nKratky plot, I * q^2 vs q: S=smeared"
q2C = q*q*(C - B)
q2S = q*q*(S - B)
KratkyPlot.SetTitle(title)
KratkyPlot.addtrace(lnq, q2S, "S")
KratkyPlot.printplot()
title = "\nKratky plot, I * q^2 vs q: C=input, S=smeared"
KratkyPlot.SetTitle(title)
KratkyPlot.addtrace(lnq, q2C, "C")
KratkyPlot.printplot()

with the right data, produces plots of and :

Kratky plot, I * q^2 vs q: C=input, S=smeared
x: min=-7.898   step=0.0889226   max=-1.49558
y: min=-0.107876   step=0.199276   max=4.2762
 ------------------------------------------------------------------------- 
|           C                                                             |
|        CCCCCC                                                           |
|      CCC    CCC                                                         |
|     CC        CC                                                        |
|    CC          CC                                                       |
|   CC            C                                                       |
|   C              C                                                      |
|  C                C                                                     |
| CC                CC                                                    |
|CC                  C                                                    |
|                     C                                                   |
|C                    CC                                                  |
|                      C                                                  |
|                       C                                                 |
|                        C                                                |
|                         C                                               |
|                         CC                                              |
|                           C                                             |
|                            CC                                           |
|                             CC                                          |
|                               CCC                                       |
|                                  CCCCCC                            CCCC |
|SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC|
 ------------------------------------------------------------------------- 

Source code documentation

class jldesmear.api.textplots.Screen(MaxRow=25, MaxCol=75, Symbol='O')[source]

plotting canvas

SetTitle(title)[source]

define a plot title

Parameters:title (str) – the title of the plot
addtrace(x, y, symbol='O')[source]

add the (x,y) trace to the plot with the given symbol

Parameters:
  • x – array (list) of abcissae
  • y – array (list) of ordinates
  • symbol – plotting character
make_buffer(rows=None, cols=None)[source]

prepare a screen buffer

paintbuffer()[source]

plot the traces on the screen buffer data scaling functions are offset by +1 for plot frame

printplot()[source]

plot to stdout

residualsplot(z, title=None)[source]

convenience to plot z vs point number

Parameters:z (numpy.ndarray) – ordinates (standardized residuals)
xyplot(x, y, title=None)[source]

convenience to plot y(x)

Parameters:
  • x (numpy.ndarray) – abcissae
  • y (numpy.ndarray) – ordinates