Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for release candidate v6.11.0.3rc1 #38592

Merged
merged 129 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
902fcd1
Replace boost ends_with with std::string equivalent.
thomashampson Oct 29, 2024
18ada7e
Merge pull request #38482 from peterfpeterson/cppcheck_suppressions_o…
peterfpeterson Dec 6, 2024
9e4c44f
Ignore in-source build of conda
peterfpeterson Dec 5, 2024
f64d89f
Move muon loader confidence check out of exec method
robertapplin Oct 30, 2024
dceeace
Add system tests for muon loading
robertapplin Oct 23, 2024
375996c
Merge pull request #38479 from peterfpeterson/muon-loader-confidence
peterfpeterson Dec 6, 2024
83ebb0b
Merge pull request #38485 from peterfpeterson/ignore_conda_build
peterfpeterson Dec 6, 2024
7d1de1e
Fix cppcheck warnings and remove unused headers
peterfpeterson Dec 9, 2024
7249bd2
Merge pull request #38496 from peterfpeterson/cppcheck_fixes
peterfpeterson Dec 10, 2024
b4e0a2a
#38451 Sibling: Create MatrixWorkspace::plot_type property (#38495)
ktactac-ornl Dec 10, 2024
c631831
Move muon hdf4 loaders to muon library
robertapplin Dec 5, 2024
15eb461
Merge pull request #38508 from peterfpeterson/38214-move-muon-hdf4-lo…
peterfpeterson Dec 13, 2024
96ab99b
Log cppcheck command during configure step
peterfpeterson Dec 12, 2024
c937344
Add QTransform base class
rosswhitfield Dec 10, 2024
7bc5372
Add tests for QTransform
rosswhitfield Dec 12, 2024
8eac2ec
Add MagneticFormFactorCorrectionMD algorithm
rosswhitfield Dec 13, 2024
4a6b734
Add tests for MagneticFormFactorCorrectionMD
rosswhitfield Dec 13, 2024
bd055f1
Update docs for MagneticFormFactorCorrectionMD
rosswhitfield Dec 16, 2024
af018dd
Update CppCheck_Suppressions
rosswhitfield Dec 16, 2024
84968f1
Add release notes
rosswhitfield Dec 16, 2024
2cfa9cc
#38487 Sibling - Bugfix: isDistribution After Divide of Two RaggedWor…
ktactac-ornl Dec 16, 2024
5e9e0c5
Fixing face centered lattice
zjmorgan Dec 16, 2024
c95bf2a
Merge pull request #38516 from mantidproject/fix_reflection_condition…
peterfpeterson Dec 16, 2024
9dd36cf
Change atom labels to the ones that were supplied
peterfpeterson Dec 17, 2024
e346929
Switch to generated DllConfig.h
peterfpeterson Dec 17, 2024
beb0099
Merge pull request #38521 from rosswhitfield/MagneticFormFactorCorrec…
rosswhitfield Dec 18, 2024
4c0202f
Remove MantidKernel/System.h
peterfpeterson Dec 18, 2024
da985e5
Remove empty unit tests
peterfpeterson Dec 18, 2024
bd660f4
Merge pull request #38527 from peterfpeterson/cppcheck_command
peterfpeterson Dec 18, 2024
cc1d371
Merge pull request #38528 from peterfpeterson/ewm8669_isotropic_labels
peterfpeterson Dec 18, 2024
a3addd2
Merge pull request #38531 from peterfpeterson/38457_sinq_system_h
peterfpeterson Dec 19, 2024
5b8b829
Merge pull request #38533 from peterfpeterson/38457_remove_includes
peterfpeterson Dec 19, 2024
a0b77af
solve the interpolation issue
Dec 19, 2024
da86e0b
Merge pull request #38540 from peterfpeterson/interpo_issue_fix
peterfpeterson Dec 20, 2024
19d66fd
Remove unused MantidKernel/System.h import
peterfpeterson Dec 20, 2024
18cde14
Merge pull request #38547 from peterfpeterson/38457_system_h_in_cpp
peterfpeterson Dec 27, 2024
565cc39
Move from MantidKernel/System.h to DllConfig.h
peterfpeterson Dec 23, 2024
bb30eb0
Add support for histogram ragged workspaces with density=true
peterfpeterson Dec 31, 2024
e81b9fc
Advance to what is on main
peterfpeterson Jan 3, 2025
97bf4ac
Merge pull request #38553 from peterfpeterson/38457_more_places
peterfpeterson Jan 3, 2025
8a350da
Merge pull request #38554 from peterfpeterson/pre-commit-ci-update-co…
peterfpeterson Jan 3, 2025
2636807
Update developer dependencies
peterfpeterson Nov 4, 2024
d19ed26
Add conda-verify to quiet packaging warning
peterfpeterson Nov 26, 2024
98b4343
Replace nexus with its dependencies
peterfpeterson Nov 26, 2024
6acf1c1
First copying of files into NexusCpp subpackage
peterfpeterson Nov 27, 2024
94882a6
Add tests which compile but fail
peterfpeterson Nov 27, 2024
cd8b293
Remove files that implement xml backend
peterfpeterson Nov 27, 2024
1326ba3
Remove ifdef for xml
peterfpeterson Nov 27, 2024
1842b0c
Add test for unlimited arrays
peterfpeterson Nov 27, 2024
4d4e768
Fix cppcheck warnings
peterfpeterson Nov 27, 2024
441d26e
Remove NeXusStream class
peterfpeterson Dec 2, 2024
cc75a73
Fix compiler warnings and cppcheck
peterfpeterson Dec 2, 2024
1c62348
Give cpp tests standard extension
peterfpeterson Dec 2, 2024
ff3c053
Move contents of nxconfig into napiconfig
peterfpeterson Dec 2, 2024
b362ba8
Bare minimum to get the code to compile and link as c++
peterfpeterson Dec 2, 2024
27fb948
Lots of little changes to make it more c++ ish
peterfpeterson Dec 2, 2024
11b93a9
Make test errors clearer
peterfpeterson Dec 3, 2024
36f6e97
Change import from nexus to MantidNexusCpp
peterfpeterson Dec 3, 2024
9b06b64
Fix cppcheck issues
peterfpeterson Dec 4, 2024
9cada48
Undo cppcheck fix
peterfpeterson Dec 6, 2024
426c5f0
Fix cppcheck issues in nexuscpp
peterfpeterson Dec 4, 2024
4710063
Refactor printing into utility function
peterfpeterson Dec 9, 2024
c4dcc85
Create external data files on the fly
peterfpeterson Dec 9, 2024
2ef5395
Always return that creating the attribute was ok
peterfpeterson Dec 10, 2024
d6376c4
Fix cppcheck issues
peterfpeterson Dec 10, 2024
0baa2e0
Remove incorrect imports
peterfpeterson Dec 10, 2024
52aadb5
Fix compiler warnings
peterfpeterson Dec 11, 2024
cb5c7d5
Stop using deprecated functions
peterfpeterson Dec 11, 2024
ffbb9f3
Fix cppcheck issues
peterfpeterson Dec 12, 2024
1727918
Remove system nexus finder
peterfpeterson Dec 12, 2024
cbe862c
Change error reporting function to take const string
peterfpeterson Dec 12, 2024
64fbef3
Remove deprecated function
peterfpeterson Dec 12, 2024
381510e
Make final parameter const for clang
peterfpeterson Dec 12, 2024
a5fb713
Do not capture exception that is rethrown
peterfpeterson Dec 12, 2024
0e3306f
Import nxconfig to help windows build
peterfpeterson Dec 12, 2024
5c29a5a
Change order of modules
peterfpeterson Dec 12, 2024
13a968f
Skip clang compiler rather than intel
peterfpeterson Dec 12, 2024
45a40e3
Copy configuration from Kernel to fix windows
peterfpeterson Dec 12, 2024
5875e92
Remove wrong header file
peterfpeterson Dec 13, 2024
b5e11b4
Change signature to quiet msvs warnings
peterfpeterson Dec 13, 2024
6893cf7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 13, 2024
e834a20
Remove unused setnumberformat function
peterfpeterson Dec 13, 2024
70a95d6
Use strdup variant on windows
peterfpeterson Dec 13, 2024
8e8c858
Fix compiler warnings on windows
peterfpeterson Dec 16, 2024
d6f1d18
Change default create to hdf5
peterfpeterson Dec 16, 2024
85c5275
Skipping external file tests on windows
peterfpeterson Dec 17, 2024
dca4462
Try to make windows test errors clearer
peterfpeterson Dec 17, 2024
ebbc6c7
No longer configure packagesetup.py because nexus is gone
peterfpeterson Dec 18, 2024
6389e41
Turn off the c-hdf5 test on windows
peterfpeterson Dec 20, 2024
e59830b
Update cppcheck suppression
peterfpeterson Dec 29, 2024
2853d4c
Remove commented out code and change some magic numbers to constants
peterfpeterson Jan 3, 2025
d19bd19
Fix invalid data when MDHistoworkspace replaced and has original work…
rosswhitfield Jan 6, 2025
73c368c
Add release note
rosswhitfield Jan 6, 2025
be49167
update plotting
searscr Dec 27, 2024
bf5d0b4
update cppCheck
searscr Dec 27, 2024
b5b30ac
fix doxygen
searscr Dec 27, 2024
ed46544
Release Notes
searscr Dec 31, 2024
d450db7
Merge pull request #38555 from mantidproject/ewm7830_plotMarkerWS_ORN…
peterfpeterson Jan 6, 2025
1c096c4
Move string constants to the top of the test file
peterfpeterson Jan 6, 2025
d5cfffb
Pin scipy to less than v1.15.0
sf1919 Jan 6, 2025
f3a2228
Merge pull request #38563 from peterfpeterson/pin_scipy_Jan25_ornlnext
peterfpeterson Jan 6, 2025
5dc6ce1
Do not double read when actual matches requested
peterfpeterson Dec 26, 2024
3c6a54a
Add ability to read portions of the data
peterfpeterson Dec 27, 2024
325fb4a
Combine functions by using default values
peterfpeterson Jan 6, 2025
8e31f79
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jan 6, 2025
983d8c8
Set cmake policy CMP0177 to new
jclarkeSTFC Dec 20, 2024
d5a7794
Drop scipy pin, relax tolerance for AbinsPowderCalculatorTest
ajjackson Jan 6, 2025
57a0d30
Merge pull request #38568 from peterfpeterson/pre-commit-ci-update-co…
peterfpeterson Jan 7, 2025
8bb269a
Merge pull request #38569 from peterfpeterson/ewm8446_nexus_into_mantid
peterfpeterson Jan 7, 2025
fcd49ba
Merge pull request #38570 from peterfpeterson/38437_fix_cmake_warning…
peterfpeterson Jan 7, 2025
3a41a4c
Merge pull request #38571 from peterfpeterson/ewm8789_convert_units_r…
peterfpeterson Jan 7, 2025
1701172
Merge pull request #38572 from peterfpeterson/abins-scipy-constants-o…
peterfpeterson Jan 7, 2025
94614aa
Remove includes of MantidKernel/System.h
peterfpeterson Jan 7, 2025
ed43820
Update googletest to version 1.15.2
jclarkeSTFC Dec 20, 2024
00d2658
Merge pull request #38575 from peterfpeterson/update_googletest_1_15_…
peterfpeterson Jan 8, 2025
f7982b0
Clarify that gtest is pinned to v1.15.2
peterfpeterson Jan 8, 2025
ff47bef
Merge pull request #38576 from peterfpeterson/38332_h5util_improvements
peterfpeterson Jan 8, 2025
bc7e058
Merge pull request #38579 from peterfpeterson/38457_generate_export_h…
peterfpeterson Jan 9, 2025
e0e6386
Code cleanup
peterfpeterson Dec 20, 2024
7304aed
Improve algorithm user documentation
peterfpeterson Dec 20, 2024
8752da4
Cleanup release notes directories
peterfpeterson Dec 23, 2024
cafbc9c
More clarification on how the algorithm works
peterfpeterson Jan 6, 2025
8cea670
Remove unnecessary word
peterfpeterson Jan 6, 2025
0610193
Flip for/if for a little speed boost
peterfpeterson Jan 9, 2025
0ac1c78
Merge pull request #38585 from peterfpeterson/gtest_pin
peterfpeterson Jan 9, 2025
0453e5e
Merge pull request #38586 from rosswhitfield/fix_sliceviewer_data_exc…
rosswhitfield Jan 10, 2025
9c6d1b1
Remove clang-format suppressions
peterfpeterson Jan 9, 2025
2a4279c
Merge pull request #38589 from peterfpeterson/cc_gdo_docs
peterfpeterson Jan 10, 2025
3bc0c16
Merge pull request #38590 from peterfpeterson/38332_nexus_sorted_incl…
peterfpeterson Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update plotting
searscr committed Jan 6, 2025
commit be4916746673144c3ce8d00db71b7773571ea77b
16 changes: 15 additions & 1 deletion Framework/API/inc/MantidAPI/MatrixWorkspace.h
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ namespace Geometry {
class ParameterMap;
}

const std::vector<std::string> validPlotTypes{"plot", "scatter", "histogram", "errorbar"};
const std::vector<std::string> validPlotTypes{"plot", "marker", "histogram", "errorbar_x", "errorbar_y", "errorbar_xy"};

namespace API {
class Axis;
@@ -141,6 +141,16 @@ class MANTID_API_DLL MatrixWorkspace : public IMDWorkspace, public ExperimentInf
/// Gets MatrixWorkspace plot_type
std::string getPlotType() const;

/// Set the marker style for plotting
void setMarkerStyle(const std::string &markerType);
/// Get the marker style for plotting
std::string getMarkerStyle() const;

/// Set the size of the marker for plotting
void setMarkerSize(const float markerSize);
/// Get the size of the marker for plotting
float getMarkerSize() const;

virtual Types::Core::DateAndTime getFirstPulseTime() const;
Types::Core::DateAndTime getLastPulseTime() const;

@@ -520,6 +530,10 @@ class MANTID_API_DLL MatrixWorkspace : public IMDWorkspace, public ExperimentInf
mutable std::atomic<bool> m_indexInfoNeedsUpdate{true};
mutable std::mutex m_indexInfoMutex;

// Marker style and size, used for plotting
std::string m_marker;
float m_marker_size;

protected:
/// Getter for the dimension id based on the axis.
std::string getDimensionIdFromAxis(const int &axisIndex) const;
42 changes: 39 additions & 3 deletions Framework/API/src/MatrixWorkspace.cpp
Original file line number Diff line number Diff line change
@@ -111,12 +111,13 @@ const std::string MatrixWorkspace::yDimensionId = "yDimension";

/// Default constructor
MatrixWorkspace::MatrixWorkspace()
: IMDWorkspace(), ExperimentInfo(), m_axes(), m_isInitialized(false), m_YUnit(), m_YUnitLabel(), m_masks() {}
: IMDWorkspace(), ExperimentInfo(), m_axes(), m_isInitialized(false), m_YUnit(), m_YUnitLabel(), m_masks(),
m_marker_size(6.) {}

MatrixWorkspace::MatrixWorkspace(const MatrixWorkspace &other)
: IMDWorkspace(other), ExperimentInfo(other), m_indexInfo(std::make_unique<Indexing::IndexInfo>(other.indexInfo())),
m_isInitialized(other.m_isInitialized), m_YUnit(other.m_YUnit), m_YUnitLabel(other.m_YUnitLabel),
m_masks(other.m_masks), m_indexInfoNeedsUpdate(false) {
m_masks(other.m_masks), m_indexInfoNeedsUpdate(false), m_marker_size(6.) {
m_axes.resize(other.m_axes.size());
for (size_t i = 0; i < m_axes.size(); ++i)
m_axes[i] = std::unique_ptr<Axis>(other.m_axes[i]->clone(this));
@@ -325,7 +326,7 @@ const std::string MatrixWorkspace::getTitle() const {

/** Set the plot type of the workspace
*
* @param t :: The plot type. Must be one of: ["plot", "scatter", "histogram", "errorbar"]
* @param t :: The plot type. Must be one of: ["plot", "marker", "histogram", "errorbar_x", "errorbar_y", "errorbar_xy"]
*/
void MatrixWorkspace::setPlotType(const std::string &t) {
Run &run = mutableRun();
@@ -353,6 +354,41 @@ std::string MatrixWorkspace::getPlotType() const {
return plotType;
}

/**
* set marker type
*
* @param marker :: The Marker Type
*/
void MatrixWorkspace::setMarkerStyle(const std::string &markerType) { m_marker = markerType; }

/**
* get the marker type
*
* @return std::string :: the marker type
*/
std::string MatrixWorkspace::getMarkerStyle() const {
if (m_marker.empty())
return Kernel::ConfigService::Instance().getString("markerworkspace.marker.Style");
else
return m_marker;
}

/**
* Set the marker size for plotting
*
* @param size :: size of the marker
*/
void MatrixWorkspace::setMarkerSize(const float size) {
if (size > 0)
m_marker_size = size;
}
/**
* Get the marker size for plotting
*
* @return int :: marker size
*/
float MatrixWorkspace::getMarkerSize() const { return m_marker_size; }

void MatrixWorkspace::updateSpectraUsing(const SpectrumDetectorMapping &map) {
for (size_t j = 0; j < getNumberHistograms(); ++j) {
auto &spec = getSpectrum(j);
13 changes: 11 additions & 2 deletions Framework/API/test/MatrixWorkspaceTest.h
Original file line number Diff line number Diff line change
@@ -411,8 +411,17 @@ class MatrixWorkspaceTest : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(ws->getPlotType(), "plot");

// test valid is accepted
ws->setPlotType("scatter");
TS_ASSERT_EQUALS(ws->getPlotType(), "scatter");
ws->setPlotType("marker");
TS_ASSERT_EQUALS(ws->getPlotType(), "marker");
}

void testGetSetMarkerStyle() {
// test default
TS_ASSERT_EQUALS(ws->getMarkerStyle(), "");

// test set
ws->setMarkerStyle("square");
TS_ASSERT_EQUALS(ws->getMarkerStyle(), "square");
}

void testGetSetComment() {
14 changes: 13 additions & 1 deletion Framework/Properties/Mantid.properties.template
Original file line number Diff line number Diff line change
@@ -314,6 +314,12 @@ plots.errorbar.errorEvery = 1
# Default width of error bars in 1d plots
plots.errorbar.Width = 1.0

# Default marker style for the errorbar workspace
plots.errorbar.MarkerStyle = circle

# Default marker size for the errorbar workspace
plots.errorbar.MarkerSize = 4

# Default legend location
plots.legend.Location = best

@@ -326,8 +332,14 @@ plots.images.Colormap = viridis
# Default colorbar scale for image plots
plots.images.ColorBarScale = Linear

# Default marker style for marker workspace plots
plots.markerworkspace.MarkerStyle = vline

# Default marker size for marker workspace plots
plots.markerworkspace.MarkerSize = 6

# Profiler Default Filename
performancelog.filename = algorithmregister.out
performancelog.filename = algotimeregister.out

# Algorithm Profiler Default Status
performancelog.write = Off
Original file line number Diff line number Diff line change
@@ -333,6 +333,8 @@ void export_MatrixWorkspace() {
.def("getNumberHistograms", &MatrixWorkspace::getNumberHistograms, arg("self"),
"Returns the number of spectra in the workspace")
.def("getPlotType", &MatrixWorkspace::getPlotType, arg("self"), "Returns the plot type of the workspace")
.def("getMarkerStyle", &MatrixWorkspace::getMarkerStyle, arg("self"), "Return the marker style for the workspace")
.def("getMarkerSize", &MatrixWorkspace::getMarkerSize, arg("self"), "Returns the marker size for the workspace")
.def("getSpectrumNumbers", &getSpectrumNumbers, arg("self"),
"Returns a list of all spectrum numbers in the workspace")
.def("yIndexOfX", &MatrixWorkspace::yIndexOfX,
@@ -399,6 +401,10 @@ void export_MatrixWorkspace() {
//------------------------------------
.def("setPlotType", &MatrixWorkspace::setPlotType, (arg("self"), arg("newType")),
"Sets a new plot type for the workspace")
.def("setMarkerStyle", &MatrixWorkspace::setMarkerStyle, (arg("self"), arg("markerType")),
"Sets the marker type for the workspace")
.def("setMarkerSize", &MatrixWorkspace::setMarkerSize, (arg("self"), arg("markerSize")),
"Sets the size of the marker for the workspace")
.def("setYUnitLabel", &MatrixWorkspace::setYUnitLabel, (arg("self"), arg("newLabel")),
"Sets a new caption for the data (Y axis) in the workspace")
.def("setYUnit", &MatrixWorkspace::setYUnit, (arg("self"), arg("newUnit")),
18 changes: 16 additions & 2 deletions Framework/PythonInterface/mantid/plots/axesfunctions.py
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ def _get_data_for_plot(axes, workspace, kwargs, with_dy=False, with_dx=False):
workspace_index, distribution, kwargs = get_wksp_index_dist_and_label(workspace, axis, **kwargs)
if axis == MantidAxType.BIN:
# get_bin returns the bin *without the monitor data*
x, y, dy, dx = get_bins(workspace, workspace_index, with_dy)
x, y, dy, dx = get_bins(workspace, workspace_index, with_dy, with_dx)
vertical_axis = workspace.getAxis(1)
if isinstance(vertical_axis, mantid.api.NumericAxis):
axes.set_xlabel(vertical_axis.getUnit().unitID())
@@ -281,8 +281,22 @@ def errorbar(axes, workspace, *args, **kwargs):
keyword for MDHistoWorkspaces. These type of workspaces have to have exactly one non integrated
dimension
"""
withDy = True
withDx = False
if isinstance(workspace, mantid.api.MatrixWorkspace) and workspace.run().hasProperty("plot_type"):
plot_type = workspace.run().getProperty("plot_type").value
if plot_type == "errorbar_x":
withDy = False
withDx = True
if plot_type == "errorbar_y":
withDy = True
withDx = False
if plot_type == "errorbar_xy":
withDy = True
withDx = True

normalize_by_bin_width, kwargs = get_normalize_by_bin_width(workspace, axes, **kwargs)
x, y, dy, dx, indices, axis, kwargs = _get_data_for_plot(axes, workspace, kwargs, with_dy=True, with_dx=False)
x, y, dy, dx, indices, axis, kwargs = _get_data_for_plot(axes, workspace, kwargs, with_dy=withDy, with_dx=withDx)
if kwargs.pop("update_axes_labels", True):
_setLabels1D(axes, workspace, indices, normalize_by_bin_width=normalize_by_bin_width, axis=axis)
kwargs.pop("normalize_by_bin_width", None)
7 changes: 5 additions & 2 deletions Framework/PythonInterface/mantid/plots/datafunctions.py
Original file line number Diff line number Diff line change
@@ -404,7 +404,7 @@ def get_bin_indices(workspace):
return indices


def get_bins(workspace, bin_index, withDy=False):
def get_bins(workspace, bin_index, withDy=False, withDx=False):
"""
Extract a requested bin from each spectrum, except if they correspond to monitors

@@ -416,14 +416,17 @@ def get_bins(workspace, bin_index, withDy=False):
indices = get_bin_indices(workspace)
x_values, y_values = [], []
dy = [] if withDy else None
dx = [] if withDx else None
for row_index in indices:
y_data = workspace.readY(int(row_index))
if bin_index < len(y_data):
x_values.append(row_index)
y_values.append(y_data[bin_index])
if withDy:
dy.append(workspace.readE(int(row_index))[bin_index])
dx = None
if withDx:
dx.append(workspace.readDx(int(row_index))[bin_index])

return x_values, y_values, dy, dx


5 changes: 4 additions & 1 deletion Framework/PythonInterface/mantid/plots/mantidaxes.py
Original file line number Diff line number Diff line change
@@ -28,10 +28,11 @@

from mantid import logger
from mantid.api import AnalysisDataService as ads
from mantid.api import MatrixWorkspace
from mantid.plots import datafunctions, axesfunctions, axesfunctions3D
from mantid.plots.legend import LegendProperties
from mantid.plots.datafunctions import get_normalize_by_bin_width
from mantid.plots.utility import artists_hidden, autoscale_on_update, legend_set_draggable, MantidAxType
from mantid.plots.utility import artists_hidden, autoscale_on_update, legend_set_draggable, MantidAxType, get_plot_specific_properties


WATERFALL_XOFFSET_DEFAULT, WATERFALL_YOFFSET_DEFAULT = 10, 20
@@ -694,6 +695,8 @@ def _data_update(artists, workspace, new_kwargs=None):
spec_num = self.get_spec_number_or_bin(workspace, kwargs)
normalize_by_bin_width, kwargs = get_normalize_by_bin_width(workspace, self, **kwargs)
is_normalized = normalize_by_bin_width or (hasattr(workspace, "isDistribution") and workspace.isDistribution())
if isinstance(workspace, MatrixWorkspace):
kwargs = get_plot_specific_properties(workspace, workspace.getPlotType(), kwargs)
with autoscale_on_update(self, autoscale_on):
artist = self.track_workspace_artist(
workspace,
58 changes: 11 additions & 47 deletions Framework/PythonInterface/mantid/plots/plotfunctions.py
Original file line number Diff line number Diff line change
@@ -22,53 +22,13 @@
from mantid.api import IMDHistoWorkspace
from mantid.kernel import ConfigService
from mantid.plots import datafunctions, MantidAxes
from mantid.plots.utility import MantidAxType
from mantid.plots.utility import MantidAxType, MARKER_MAP, get_plot_specific_properties

# -----------------------------------------------------------------------------
# Constants
# -----------------------------------------------------------------------------
PROJECTION = "mantid"

MARKER_MAP = {
"square": "s",
"plus (filled)": "P",
"point": ".",
"tickdown": 3,
"triangle_right": ">",
"tickup": 2,
"hline": "_",
"vline": "|",
"pentagon": "p",
"tri_left": "3",
"caretdown": 7,
"caretright (centered at base)": 9,
"tickright": 1,
"caretright": 5,
"caretleft": 4,
"tickleft": 0,
"tri_up": "2",
"circle": "o",
"pixel": ",",
"caretleft (centered at base)": 8,
"diamond": "D",
"star": "*",
"hexagon1": "h",
"octagon": "8",
"hexagon2": "H",
"tri_right": "4",
"x (filled)": "X",
"thin_diamond": "d",
"tri_down": "1",
"triangle_left": "<",
"plus": "+",
"triangle_down": "v",
"triangle_up": "^",
"x": "x",
"caretup": 6,
"caretup (centered at base)": 10,
"caretdown (centered at base)": 11,
"None": "None",
}

# -----------------------------------------------------------------------------
# Decorators
@@ -582,23 +542,27 @@ def _set_axes_limits_from_properties(ax):


def _do_single_plot(ax, workspaces, errors, set_title, nums, kw, plot_kwargs, log_name=None, log_values=None):
# do the plotting
plot_fn = ax.errorbar if errors else ax.plot

counter = 0
for ws in workspaces:
for num in nums:
plot_fn = ax.errorbar if errors else ax.plot
if isinstance(ws, MatrixWorkspace):
plot_type = ws.getPlotType()
_plot_kwargs = get_plot_specific_properties(ws, plot_type, plot_kwargs)
if "errorbar" in plot_type or errors:
plot_fn = ax.errorbar

if log_values:
label = log_values[counter]
if len(nums) > 1:
label = f"spec {num}: {label}"

plot_kwargs["label"] = label
_plot_kwargs["label"] = label

counter += 1

plot_kwargs[kw] = num
plot_fn(ws, **plot_kwargs)
_plot_kwargs[kw] = num
plot_fn(ws, **_plot_kwargs)

_set_axes_limits_from_properties(ax)
ax.make_legend()
81 changes: 81 additions & 0 deletions Framework/PythonInterface/mantid/plots/utility.py
Original file line number Diff line number Diff line change
@@ -14,13 +14,54 @@
from matplotlib.legend import Legend
from matplotlib import colormaps
from matplotlib.container import ErrorbarContainer
from mantid.kernel import ConfigService

# -----------------------------------------------------------------------------
# Constants
# -----------------------------------------------------------------------------
# Restrict zooming out of plots.
ZOOM_LIMIT = 1e300

MARKER_MAP = {
"square": "s",
"plus (filled)": "P",
"point": ".",
"tickdown": 3,
"triangle_right": ">",
"tickup": 2,
"hline": "_",
"vline": "|",
"pentagon": "p",
"tri_left": "3",
"caretdown": 7,
"caretright (centered at base)": 9,
"tickright": 1,
"caretright": 5,
"caretleft": 4,
"tickleft": 0,
"tri_up": "2",
"circle": "o",
"pixel": ",",
"caretleft (centered at base)": 8,
"diamond": "D",
"star": "*",
"hexagon1": "h",
"octagon": "8",
"hexagon2": "H",
"tri_right": "4",
"x (filled)": "X",
"thin_diamond": "d",
"tri_down": "1",
"triangle_left": "<",
"plus": "+",
"triangle_down": "v",
"triangle_up": "^",
"x": "x",
"caretup": 6,
"caretup (centered at base)": 10,
"caretdown (centered at base)": 11,
"None": "None",
}
# Use the correct draggable method based on the matplotlib version
if hasattr(Legend, "set_draggable"):
SET_DRAGGABLE_METHOD = "set_draggable"
@@ -243,3 +284,43 @@ def convert_color_to_hex(color):
except (KeyError, TypeError):
rgb = colors.colorConverter.to_rgb(color)
return colors.rgb2hex(rgb)


def get_plot_specific_properties(ws, plot_type, plot_kwargs):
"""
Set plot specific properties from the workspace
:param ws:
:param ax:
:param errors:
:param plot_kwargs:
"""

if plot_type in ["errorbar_x", "errorbar_y", "errorbar_xy"]:
plot_kwargs["linestyle"] = "None"
plot_kwargs["marker"] = MARKER_MAP[ConfigService.getString("plots.errorbar.MarkerStyle")]
plot_kwargs["markersize"] = float(ConfigService.getString("plots.errorbar.MarkerSize"))
if "capsize" not in plot_kwargs:
plot_kwargs["capsize"] = float(ConfigService.getString("plots.errorbar.Capsize"))
if "capthick" not in plot_kwargs:
plot_kwargs["capthick"] = float(ConfigService.getString("plots.errorbar.CapThickness"))
if "errorevery" not in plot_kwargs:
plot_kwargs["errorevery"] = int(ConfigService.getString("plots.errorbar.errorEvery"))
if "elinewidth" not in plot_kwargs:
plot_kwargs["elinewidth"] = float(ConfigService.getString("plots.errorbar.Width"))
else:
if plot_type == "marker":
plot_kwargs["linestyle"] = "None"
if ws.getMarkerStyle():
plot_kwargs["marker"] = MARKER_MAP[ws.getMarkerType()]
else:
plot_kwargs["marker"] = MARKER_MAP[ConfigService.getString("plots.markerworkspace.MarkerStyle")]
marker_size = ws.getMarkerSize()
plot_kwargs["markersize"] = (
marker_size if marker_size != 6 else float(ConfigService.getString("plots.markerworkspace.MarkerSize"))
)
plot_kwargs.pop("capsize", None)
plot_kwargs.pop("capthick", None)
plot_kwargs.pop("errorevery", None)
plot_kwargs.pop("elinewidth", None)

return plot_kwargs
Original file line number Diff line number Diff line change
@@ -408,8 +408,8 @@ def test_setPlotType(self):
self.assertEqual("plot", ws1.getPlotType())

# test valid takes
ws1.setPlotType("scatter")
self.assertEqual("scatter", ws1.getPlotType())
ws1.setPlotType("marker")
self.assertEqual("marker", ws1.getPlotType())

def test_setGetMonitorWS(self):
run_algorithm("CreateWorkspace", OutputWorkspace="ws1", DataX=[1.0, 2.0, 3.0], DataY=[2.0, 3.0], DataE=[2.0, 3.0], UnitX="TOF")
34 changes: 34 additions & 0 deletions docs/source/api/python/mantid/plots/index.rst
Original file line number Diff line number Diff line change
@@ -185,6 +185,40 @@ when giving the projection:
ax.plot_wireframe(x,y,z) #for arrays
fig.show()
Matrix Workspace Plotting
=========================

The `setPlotType()` method allows you to define how a workspace should be visualized when plotting. The following plot types are available:

- **marker**:
A scatter plot where data points are displayed as markers without connecting lines. Ideal for visualizing individual data points.

- **plot**:
A standard line plot that connects data points using lines. This is the default visualization for continuous data.

- **errorbar_x**:
A plot with error bars in the x-direction only. Uses `dataX` for the x-values, `dataY` for the y-values, and `dataDx` for the x-error values.

- **errorbar_y**:
A plot with error bars in the y-direction only. Uses `dataX` for the x-values, `dataY` for the y-values, and `dataE` for the y-error values.

- **errorbar_xy**:
A plot with error bars in both x- and y-directions. Uses `dataX` for the x-values, `dataY` for the y-values, `dataDx` for the x-error values, and `dataE` for the y-error values.

These options can be set using:

.. code-block:: python
workspace.setPlotType('marker') # or 'plot', 'errorbar_x', 'errorbar_y', 'errorbar_xy'
workspace.getPlotType() # returns the current plot type
.. figure:: ../../../../images/mantid_plot_types.png
:align: center
:figwidth: image



Types of functions
==================

184 changes: 96 additions & 88 deletions docs/source/concepts/PropertiesFile.rst

Large diffs are not rendered by default.

Binary file added docs/source/images/mantid_plot_types.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions qt/python/mantidqt/mantidqt/widgets/superplot/presenter.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
from .model import SuperplotModel

from mantid.kernel import ConfigService
from mantid.api import mtd
from mantid.api import mtd, MatrixWorkspace
from mantid.plots.utility import MantidAxType, legend_set_draggable
from mantid.plots.plotfunctions import MARKER_MAP
from mantid.plots import MantidAxes
@@ -479,7 +479,12 @@ def _plot_selection(self):
if ws_name not in mtd:
continue
ws = mtd[ws_name]
if self._error_bars:
error_ws = False
if isinstance(ws, MatrixWorkspace):
plot_type = ws.getPlotType()
if "errorbar" in plot_type:
error_ws = True
if self._error_bars or error_ws:
lines = axes.errorbar(ws, **kwargs)
color = lines.lines[0].get_color()
else: