wiki:rp_xml_ele_curve

<curve>

A curve object represents a list of (x,y) data points:

  <curve id="single">
    <about>
      <label>Single curve</label>
      <description>This is an example of a single curve.</description>
    </about>
    <xaxis>
      <label>Time</label>
      <description>Time during the experiment.</description>
      <units>s</units>
    </xaxis>
    <yaxis>
      <label>Voltage v(11)</label>
      <description>Output from the amplifier.</description>
      <units>V</units>
    </yaxis>
    <component>
      <xy>
0.01 0.990049505363
2.008 -0.140760579036
4.006 -0.129662618375
6.004 0.137247325002
8.002 -0.016382854697
       </xy>
     </component>
   </curve>

When a curve is produced as an output result, its <about><label> is used to identify the result in the combobox used to select various results. The <about><description> is displayed in a tooltip when you mouse over the selector, giving a more detailed explanation of what this result represents. Similarly, the <xaxis><description> and <yaxis><description> pop up in a tooltip when you mouse over either axis. They give more information about the physical quantities being plotted.


  <curve id="multi1">
    <about>
      <group>Multiple curves</group>
      <label>Factor a=1</label>
      <description>This is an example of multiple curves on the same plot.</description>
    </about>
    <xaxis>
      <label>Frequency</label>
      <description>Frequency of the input source.</description>
      <units>Hz</units>
      <scale>log</scale>
    </xaxis>
    <yaxis>
      <label>Current</label>
      <description>Current through the pull-down resistor.</description>
      <units>uA</units>
      <scale>log</scale>
    </yaxis>
    <component>
      <xy>
0.01 100.695555006
2.008 2.00310872589
4.006 4.01065419167
6.004 10.689155879
8.002 32.036383087
      </xy>
    </component>
  </curve>

  <curve id="multi2">
    <about>
      <group>Multiple curves</group>
      <label>Factor a=2</label>
      <description>This is an example of multiple curves on the same plot.</description>
    </about>
    <xaxis>
      <label>Frequency</label>
      <description>Frequency of the input source.</description>
      <units>Hz</units>
      <scale>log</scale>
    </xaxis>
    <yaxis>
      <label>Current</label>
      <description>Current through the pull-down resistor.</description>
      <units>uA</units>
      <scale>log</scale>
    </yaxis>
    <component>
      <xy>
0.01 101.395947979
2.008 8.05698869204
4.006 64.4379002629
6.004 686.00535265
8.002 8212.69139005
      </xy>
    </component>
  </curve>

You can overlay two or more curves on the same plot as shown here, by using the same <group> tag in all of the overlayed curves. In that case, the <label> tag is used to describe information particular to each curve. The <label> appears in the pop-up when you mouse over a data point on the curve.

Styles

To change the color or line style of a curve, you may include a <style> element in the curve's <about> element:

<output>
  <curve>
    <about>
      <style>-color green -linestyle dashed</style>
    </about>
    ...
  <curve>
</output>

Style options are given as option flag and value pairs separated by spaces. The supported style options are:

-color

Can be a color name or a hexidecimal color, e.g. "green" or "#00FF00"

-linestyle

Can be "solid", "dashed" or "dotted". The default line style is solid.

Scatter Plots

You can create xy-scatter plots by changing the type of plot to "scatter". The default action for this widget is to create line plots. If you do not specify the type of plot in the about stanza of the xml, a line plot will be created.

In TCL you could say:

$driver put output.curve(scatterplot).about.type "scatter"

to produce xml like this:

...
<output>
    <curve id="scatterplot">
        <about>
            <type>scatter</type>
        </about>
        ... xaxis, yaxis, components ...
    </curve>
</output>

You can see working code in the zoo of examples in the curve example or on the hub in the directory /apps/rappture/examples/zoo/curve.

Last modified 9 years ago Last modified on Jun 23, 2015 1:37:27 PM