Open briochemc opened 2 years ago
You can always modify these sorts of properties after the fact by saving the handles to the contourfcmap object(s), which are returned by the optional output argument. Handles are provided for everything created, including contourgroups (recolor method only), patches (calccontour method only), and the psuedocolorbar child objects (axis, colorbar, patches).
Properly parsing contour properties and applying them as part of the contourfcmap call would not be a trivial task. I probably won't add that capability unless I find an example where modifying the properties after creation does not suffice. Likewise for the more modern keyword syntax, which would be a bear to keep back-compatible. So sorry. :-)
Not sure how far you want to keep backwards compatibility, but FWIW, I've been using the "new" argument validation (introduced in R2019b) and it works like a charm to handle old and new syntax. Here's an example with contour properties:
function custom_contourf(z, opt)
arguments
z
opt.?matlab.graphics.chart.primitive.Contour % Accept all contour key-value pair args
opt.LineStyle = ':' % set one default one
end
optcell = namedargs2cell(opt); % convert struct to cell of key-value pairs
contourf(z, optcell{:}, 'linestyle', 'none'); % filled contour without lines
hold on
contour(z, 'linecolor', 'black', optcell{:}); % contour lines added
end
and then old and new syntax should work automatically:
>> custom_contourf(z)
>> custom_contourf(z, linestyle='--') % new syntax
>> custom_contourf(z, 'linestyle', '--', 'linecolor', 'red', 'linewidth', 5) % old syntax + extra changes
plots those:
If you are OK with this approach, I can try a PR when I find the time :)
First things first, congratulations, this is such a neat package!
Hopefully this is request is little work. It would be great if the keyword (value/pair) arguments of
contourf
were also valid forcontourfcmap
. For instance, I am looking for the line properties, such asLineColor
,LineStyle
, andLineWidth
. The motivation is to be able to customize plots as below for examplewhich is done by first plotting without the lines via
and then adding the specific lines of interest back with simple
contour
calls, e.g.,for example.
Because any contour line style/color can be added after removing them all, my request can probably be reduced to being able to pass the
LineStyle
, i.e.,Or, even better IMHO,
with the more "modern" keyword argument syntax.
I realize this would probably require figuring out some syntax for controlling the colorbar ticks and tick labels, but maybe I'm wrong?