-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround and test script for legendflex legend text
- Loading branch information
Showing
3 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
\documentclass{article} | ||
|
||
\usepackage{pgfplots} | ||
\pgfplotsset{compat=newest} | ||
%% the following commands are needed for some matlab2tikz features | ||
\usetikzlibrary{plotmarks} | ||
\usetikzlibrary{arrows.meta} | ||
\usepgfplotslibrary{patchplots} | ||
\usepackage{grffile} | ||
\usepackage{amsmath} | ||
|
||
%% you may also want the following commands | ||
%\pgfplotsset{plot coordinates/math parser=false} | ||
%\newlength\figureheight | ||
%\newlength\figurewidth | ||
|
||
\begin{document} | ||
\input{figure.tex} | ||
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
% Basic legendflex example from the legendflex repository | ||
% https://github.com/kakearney/legendflex-pkg | ||
% Then save figure with matlab2tikz | ||
|
||
clear | ||
clc | ||
close all | ||
|
||
figure('color','w'); | ||
|
||
linespec = [repmat({'r';'b';'g';'c';'m'},2,1), ... | ||
[repmat({'-'}, 5, 1); repmat({'--'}, 5, 1)]]; | ||
|
||
|
||
x = [0 10]; | ||
y = (1:10)'*x; | ||
lbl = cellstr(num2str((1:10)')); | ||
|
||
% hln = NaN(1,2); | ||
hln(:,2) = plot(x, y); | ||
set(hln(:,2), {'color','linestyle'}, linespec); | ||
|
||
[hl(2).leg, hl(2).obj, hl(2).hout, hl(2).mout] = ... | ||
legendflex(hln(1:5,2), lbl(1:5), ... | ||
'anchor', {'nw','nw'}, ... | ||
'buffer', [5 -5], ... | ||
'fontsize',10, ... % has to match document. Otherwise box not wide enough | ||
'xscale',0.5, ... | ||
'title', 'Color'); | ||
[hl(3).leg, hl(3).obj, hl(3).hout, hl(3).mout] = ... | ||
legendflex(hln([1 6],2), {'thing 1', 'thing 2'}, ... | ||
'ref', hl(2).leg, ... | ||
'anchor', {'ne','nw'}, ... | ||
'buffer', [5 0], ... | ||
'FontName', 'Times New Roman', ... | ||
'fontsize', 10, ... | ||
'title', 'Line'); | ||
|
||
% Save figure | ||
matlab2tikz('figure.tex', ... | ||
'strictFontSize', false); |