Ticket #2657 (closed: fixed)

Opened 10 years ago

Last modified 5 years ago

Better control of error bars from Python

Reported by: Nick Draper Owned by: Russell Taylor
Priority: major Milestone: Release 2.0
Component: MantidPlot Keywords:
Cc: Blocked By:
Blocking: Tester: Nick Draper

Description

From qtiplot handbook:

Error Bars

Having a plot layer l, you can add error bars to a data curve c, named curveName, using the following methods:

err1 = l.addErrorBars(c, Table *t, QString errColName, int type = 1, double width = 1, int capLength = 8, color = Qt.black, throughSymbol = True, minusSide = True, plusSide = True)
err2 = l.addErrorBars(curveName, Table *t, QString errColName, int type = 1, double width = 1, int capLength = 8, color = Qt.black, throughSymbol = True, minusSide = True, plusSide = True)
Each data curve, c, can have attached a list of error bars:

errors = c.errorBarsList()
The properties of an error bar curve can be accesses, via the following methods:

err = c.errorBarsList()[0]
for i in range(0, err.dataSize()):
	print err.errorValue(i)

err.capLength()
err.width()
err.color()
err.direction()
err.xErrors()
err.throughSymbol()
err.plusSide()
err.minusSide()
c = err.masterCurve() # reference to the master curve to which the error bars curve is attached.
err.detachFromMasterCurve() # equivalent to c.removeErrorBars(err)
... and can be modified, via the following methods:

err.setCapLength(12)
err.setWidth(3)
err.setColor(Qt.red)
err.setDirection(ErrorBarsCurve.Vertical)
err.setXErrors(True) # equivalent to err.setDirection(ErrorBarsCurve.Horizontal)
err.drawThroughSymbol(True)
err.drawPlusSide(True)
err.drawMinusSide(False)
err.setMasterCurve(c)
You can remove all error bars attached to a curve using:

c.clearErrorBars()

Change History

comment:1 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 28 to Iteration 29

Bulk move of tickets at the end of iteration 28

comment:2 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 29 to Iteration 30

"New" tickets moved at the code freeze of iteration 29

comment:3 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 30 to Iteration 31

Bulk move of tickets to iteration 31 at the iteration 30 code freeze

comment:4 Changed 9 years ago by Russell Taylor

The thing that stops this being trivial is that we handle error bars for 'Mantid curves' completely differently to QtiPlot. In the latter, the errors are stored in a completely separate 'PlotCurve' specialisation - which then has all the methods referred to above. For us, it's all within the 'MantidCurve'.

Maybe the answer is to have a common interface which holds all these settings, use that for each type of curve and expose that to python.

comment:5 Changed 9 years ago by Russell Taylor

  • Status changed from new to accepted

comment:6 Changed 9 years ago by Russell Taylor

Add class holding settings for error bars. Re #2657.

Very simple class of attributes and getters & setters, pulled out of QwtErrorPlotCurve.

Changeset: ad3d3b394c03287e90f1f01e5c159aa6a4523141

comment:7 Changed 9 years ago by Russell Taylor

Expose ErrorBarSettings to python. Re #2657.

Changeset: 14cddb6ceb9fb63a405d1c698c8a1000bd7780d7

comment:8 Changed 9 years ago by Russell Taylor

Add methods to get error bar settings for a curve. Re #2657.

Although a Mantid curve's error bar settings can be accessed, they aren't applied yet.

Changeset: cb26d897c2e3e85177d7185366dd204cf6bd0bd7

comment:9 Changed 9 years ago by Russell Taylor

Indentation changes only. Re #2657.

Changeset: b1ca7c5b30490153091cf1ba105e76817c25460d

comment:10 Changed 9 years ago by Russell Taylor

MantidCurves now take notice of error bar settings. Re #2657.

Though they can only be customised from python at the moment, and are not retained on saving a project.

Changeset: 20b8bc4f94edaf6de59dcec85eef63fef327ece7

comment:11 Changed 9 years ago by Russell Taylor

Try to fix unixy places. Re #2657.

Changeset: fc62f35ca29e162b40a140bf03ee086955dfacc5

comment:12 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 32 to Iteration 33

Moved to iteration 33 at iteration 32 code freeze

comment:13 Changed 9 years ago by Russell Taylor

  • Milestone changed from Iteration 33 to Iteration 32

Just need to write the wiki documentation.

comment:14 Changed 9 years ago by Russell Taylor

  • Status changed from accepted to verify
  • Resolution set to fixed

Documentation is at: http://www.mantidproject.org/MantidPlot:_Error_Bars

Follow-up ticket #4469 has been created to improve Mantid curve error bars in general in MantidPlot.

Last edited 9 years ago by Russell Taylor (previous) (diff)

comment:15 Changed 9 years ago by Nick Draper

  • Status changed from verify to verifying
  • Tester set to Nick Draper

comment:16 Changed 9 years ago by Nick Draper

  • Status changed from verifying to closed

passed testing

comment:17 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 3504

Note: See TracTickets for help on using tickets.