icyphy / ptII

Ptolemy II is an open-source software framework supporting experimentation with actor-oriented design.
https://ptolemy.eecs.berkeley.edu/ptolemyII
Other
98 stars 43 forks source link

Plotter should be better about displaying times #72

Open cxbrooks opened 16 years ago

cxbrooks commented 16 years ago

Note: the issue was created automatically with bugzilla2github tool

Original bug ID: BZ#141 From: @cxbrooks Reported version: 7.1.devel CC: pt-dev@chess.eecs.berkeley.edu

cxbrooks commented 16 years ago

Ian Brown writes:

It's difficult to interpret the plots because the x a-axis is in seconds. It would be nice if one could configure the units to it could display 6am, 7am etc.

The Ptolemy Plotter uses PtPlot, which is the first Java program Edward and I wrote. PtPlot is based on XGraph. Ptplot can display data with different legends by clicking on plot format button in the plot and then changing the xticks and yticks ptolemy.plot.PlotBase describes the format: http://ptolemy.eecs.berkeley.edu/ptolemyII/ptIIlatest/ptII/doc/codeDoc/ptolemy/plot/PlotBox.html says:

 XTicks: label position, label position, ...
 YTicks: label position, label position, ...
 

A label is a string that must be surrounded by quotation marks if it contains any spaces. A position is a number giving the location of the tick mark along the axis. For example, a horizontal axis for a frequency domain plot might have tick marks as follows:

 XTicks: -PI -3.14159, -PI/2 -1.570795, 0 0, PI/2 1.570795, PI 3.14159
 

Tick marks could also denote years, months, days of the week, etc.

So, it is possible to use the ticks to display the time. The tricky part is that properly managing the location of the ticks is a real art. It is difficult to determine how many ticks to display, the easiest way is to measure the length of the string to be displayed and then make some guesses. The code that does this is somewhat ugly. I see two ways of doing this. 1) Create a DatePloter actor that would brute force set the xticks parameter. The parameters of the plotter would have include some notion of whether the input was in seconds, hours, days, years etc. 2) Update the PlotBox to properly handle dates. We've had requests for this in the past. The second choice is the preferred option.