Why does my code plot the same thing twice

Im trying to plot some data but it seems like it plots my data twice for some reason. Attached is the plotting file, the data import file and some sample data.
Image of the resulting plot:
It worked with other data sets but for some reason i dont know why it plots everything twice in the same figure.

6 Comments

"it seems like it plots my data twice" - why do you assume this? Please mention, what you observe, not only your conclusion.
If you use the debugger to step through your code line by line, can you find the line, which triggers the 2nd drawing?
You are correct I dont know for sure. I tried to run the code line by line with the debugger and I cant figure out exactly why it makes two titles. As soon as I run the line with the title it prints two titles in the figure. everything up until then looks normal.
Okay. There are two titles, as far as I understand. You have found the line, which creates it. If you mention, which line it is, I could take a look onto it also.
By the way,
titlestringbf = join(['\textbf{',titlestring,'}']);
joins the char vector ['\textbf{',titlestring,'}'] with nothing. Omit the "join" for simplicity.
Yes of course, sorry it should be line 41. And thank you for the string tip!
I think I found the issue. It was with the
t = title('FontSize',16,'interpreter','latex','string',titlestringbf);
I just removed
'string',titlestringbf
And input the string variable as the first input in the title function.
@Jan Thank you for the helpful answers!

Sign in to comment.

Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!