Ticket #2658 (closed: fixed)
Improve python control of Contour plots
Reported by: | Nick Draper | Owned by: | Russell Taylor |
---|---|---|---|
Priority: | major | Milestone: | Release 2.0 |
Component: | MantidPlot | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Tester: | Anders Markvardsen |
Description
From qtiplot handbook:
The plot functions above return a reference to the multilayer plot window. If you need a reference to the spectrogram object itself, you can get it as shown in the example below: m = newMatrix("TestMatrix", 1000, 800) m.setFormula("x*y") m.calculate() g = plot(m, Layer.ColorMap) s = g.activeLayer().spectrogram(m) s.setColorBarWidth(20) It is possible to fine tune the plots created from a matrix: m = newMatrix("TestMatrix", 1000, 800) m.setFormula("x*y") m.calculate() s = newGraph().activeLayer().plotSpectrogram(m, Layer.ColorMap) s.setContourLevels((20.0, 30.0, 60.0, 80.0)) s.setDefaultContourPen(QtGui.QPen(Qt.yellow)) # set global pen for the contour lines s.setLabelsWhiteOut(True) s.setLabelsColor(Qt.red) s.setLabelsFont(QtGui.QFont("Arial", 14)) s.setLabelsRotation(45) s.showColorScale(Layer.Top) s.setColorBarWidth(20) As you have seen earlier, you can set a global pen for the contour lines, using: s.setDefaultContourPen(QtGui.QPen(Qt.yellow)) You can also assign a specific pen for each contour line, using the function below: s.setContourLinePen(index, QPen) or you can automatically set pen colors defined by the color map of the spectrogram: s.setColorMapPen(bool on = True) You can also use any of the following functions: s.setMatrix(Matrix *, bool useFormula = False) s.setUseMatrixFormula(bool useFormula = True)# calculate data to be drawn using matrix formula (if any) s.setLevelsNumber(int) s.showColorScale(int axis, bool on = True) s.setGrayScale() s.setDefaultColorMap() s.setCustomColorMap(LinearColorMap map) s.showContourLineLabels(bool show = True) # enable/disable contour line labels s.setLabelsOffset(int x, int y) # offset values for all labels in % of the text size s.updateData()
Change History
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:5 Changed 9 years ago by Russell Taylor
Enable customisation of color fill plots from python. Re #2658.
Changeset: 958d80dc20155300b8989f45c57319438cec3d25
comment:6 Changed 9 years ago by Russell Taylor
- Status changed from accepted to verify
- Resolution set to fixed
Documentation has been updated at http://www.mantidproject.org/MantidPlot:_Image_and_Contour_Line_Plots_%28Spectrograms%29
(Note that there are slight differences to the qtiplot commands shown in the description).
comment:7 Changed 9 years ago by Anders Markvardsen
- Status changed from verify to verifying
- Tester set to Anders Markvardsen
Note: See
TracTickets for help on using
tickets.
Bulk move of tickets at the end of iteration 28