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

Custom labels in colorbar #895

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 20 additions & 1 deletion src/matlab2tikz.m
Original file line number Diff line number Diff line change
Expand Up @@ -4562,9 +4562,18 @@ function warnFacetedInterp(m2t)
end
end

% Merge them together in axisOptions.
% Merge them together in axisOptions.
axisOptions = opts_add(axisOptions, strtrim(['colorbar ', cbarTemplate]));


%color map ticks
[m2t, options] = getAxisOptions(m2t, handle, 'y');
Copy link
Contributor

@miscco miscco May 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can just pass cbarStyleOptions directly.

[m2t, cbarStyleOptions] = getAxisOptions(m2t, handle, 'y', cbarStyleOptions);

Then there is no need to merge below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally getAxisOptions assumes that options is a valid container, so that would break most likely

options = opts_remove(options,'separate axis lines','every outer y axis line/.append style','every y tick label/.append style');

cbarStyleOptions = opts_merge(cbarStyleOptions,options);



if ~isempty(cbarStyleOptions)
axisOptions = opts_addSubOpts(axisOptions, ...
'colorbar style', cbarStyleOptions);
Expand Down Expand Up @@ -6392,6 +6401,16 @@ function printAll(m2t, env, fid)
opts = cat(1, opts, {key, value});
end
end
function opts = opts_append_unique(opts, key, value)
% append a key-value pair to an options array (duplicate keys allowed)
if ~exist('value','var')
value = '';
end
value = char(value);
if ~opts_has(opts, key)
opts = cat(1, opts, {key, value});
end
end
function opts = opts_append_userdefined(opts, userDefined)
% appends user-defined options to an options array
% the userDefined options can come either as a single string or a cellstr that
Expand Down
13 changes: 13 additions & 0 deletions test/examples/colorMap/example_colorMap.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function example_colorMap()

f= figure();
h=pcolor(peaks);

hcb=colorbar;
set(hcb,'YTick',[-6 0 6 ],'YTickLabel',{'Good','Normal','Bad'})
ylabel(hcb, 'Some Axis Name');
matlab2tikz('figurehandle',f,...
'filename','example_colorMap.tex' ,...
'showInfo', false,...
'standalone', true);
close(f)
Binary file added test/examples/colorMap/example_colorMap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.