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

Levels in contourf #1140

Open
samuelestenlund opened this issue Mar 28, 2024 · 2 comments
Open

Levels in contourf #1140

samuelestenlund opened this issue Mar 28, 2024 · 2 comments

Comments

@samuelestenlund
Copy link

I get an error in Matlab when tring to generate a tikz-file from a contourf-figure containing levels.

Example below. If I take away the levels it works. If I make contour instead of contourf (the f for fill is the difference), it works. But not like this.

`x = [0 1 2];
y = [1 2];
d = [1 2 2; 2 2 3];
levels = 0:0.5:3;

close all
figure()
contourf(x,y,d,levels)
matlab2tikz('testcontour.tikz','showinfo',false)`

@samuelestenlund
Copy link
Author

The error message from Matlab is as follows:

`Error using vertcat
Dimensions of arrays being concatenated are not consistent.

Error in matlab2tikz>drawFilledContours (line 3013)
backdrop = [setdiff(LevelList, Levels), 4;

Error in matlab2tikz>drawContourHG2 (line 2879)
[m2t, str] = drawFilledContours(m2t, h, contours, istart, nrows, custom);

Error in matlab2tikz>drawContour (line 2826)
[m2t, str] = drawContourHG2(m2t, h, custom);

Error in matlab2tikz>handleObject (line 3172)
[m2t, str] = feval(actualHandler, m2t, h, custom);

Error in matlab2tikz>drawHggroup (line 3103)
[m2t, str] = handleObject(m2t, h, @drawContour);

Error in matlab2tikz>handleObject (line 3172)
[m2t, str] = feval(actualHandler, m2t, h, custom);

Error in matlab2tikz>handleAllChildren (line 697)
[m2t, str] = handleObject(m2t, child, @drawHggroup);

Error in matlab2tikz>drawAxes (line 892)
[m2t, childrenEnvs] = handleAllChildren(m2t, handle);

Error in matlab2tikz>saveToFile (line 485)
m2t = drawAxes(m2t, relevantAxesHandle);

Error in matlab2tikz (line 337)
m2t = saveToFile(m2t, fid, fileWasOpen);

Error in Untitled (line 9)
matlab2tikz('testcontour.tikz','showinfo',false)`

@samuelestenlund
Copy link
Author

Forgive me if I use Github in the wrong way here, spamming my own thread as I take steps in the troubleshooting.

The error happens when backdrop is generated. backdrop is a 2x5 matrix where the bottom 4 rows are the x and y coordinates of the corners of the plot area. The error happens in the first row when LevelList contain more than 1 entries MORE than Levels have. The lists seem to be the same if Levels (given in the contourf-fuction originally) has values that are within the minimum and maximum values in the plot. But if Levels have values that extend outside of the data in the plot, these vectors do not match and the setdiff-function returns a vector with more than one value, making the first row of the backdrop matrix too long (the other rows are only 2 values long).

(rows 3013:3017)
backdrop = [setdiff(LevelList, Levels), 4; min(xdata(:)), min(ydata(:)); min(xdata(:)), max(ydata(:)); max(xdata(:)), max(ydata(:)); max(xdata(:)), min(ydata(:))];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant