Can you please promote this video on Reddit (in a relevant subreddit)? You'd be an angel!
@raffaelenicolapiazzolla3927Ай бұрын
Extremely detailed yet intuitive explanation, love it!
@PixelVoxelVoila2 жыл бұрын
Thank you so much! I have been hating my figures on matlab right from the start. I have gone all around internet searching for the perfect code to just plug into every figure I generate instead of having functions and complicating the code. But this was the best and very clearly explained. Thanks again!
@PhysicsLaure2 жыл бұрын
Glad I could help Anupama ! 💚
@reitrop62732 жыл бұрын
Thank you for the tutorial. I made the switch to Python some months ago, but these are still very useful guidelines (regarding font size, colours, file formats, etc.).
@PhysicsLaure2 жыл бұрын
Hi! You should def. build a little set of lines to male your figures pretty. It also keeps everything homogeneous ;)
@reitrop62732 жыл бұрын
@@PhysicsLaure Thank you for the advice. I’ll certainly do it once my “style” of figures has matured.
@MTauhaA3 жыл бұрын
Really useful tips for producing presentable figures from MATLAB. Two file exchange submissions that seem highly relevant here are: 1. Fixfig (This does quite a few things mentioned in the video for font style and marker style in MATLAB graphic objects through typing just one word) 2. export_fig (This produces high-res and correctly cropped figures for exporting from MATLAB)
@PhysicsLaure2 жыл бұрын
Hey Muhammad, 100% agree on both files. I prefer to have solutions that are independent of them as a rule of thumb, I always end up with issues downloading them, or with people who can't. Thanks for watching this video :D
@alboTBA2 жыл бұрын
Thank you a lot! I was struggling so much with the formatting!
@PhysicsLaure2 жыл бұрын
Good luck with it! Also go Bern :)
@samblake99533 ай бұрын
Great stuff!! Having a preset like that also really cuts down on the time I spend formatting plots as I will spend waaay more time than I should. Thank you!
@subhadipkarmakar2841 Жыл бұрын
Thank you very much Madam for this tutorial video😇 from India 🇮🇳
@mustafaalshaqaq23033 жыл бұрын
Nice! I liked your way of creating figures. Keep up the good work. One comment though is the "TickLength" property does not adjust well especially if you want to create small figures. I had this issue before and I always wanted to find a way to automatically take care of this issue. Also, I had this issue of the default black color used for labels, axes, ticks, etc. is not really black, I believe the default is [0.15 0.15 0.15]. I just wanted to mention this because especially in LaTeX the font is black and sometimes it becomes clear that the figure fonts are a bit lighter than the text in latex. Thanks.
@LaureMBrussolo3 жыл бұрын
Hey! Thanks for the feedback on the color. I'm going to check. Agree on TickLength, I often end up manually setting value ranges -_-
@LaureMBrussolo3 жыл бұрын
Usually for ticks, I know what range I have so I set either both bounds + 1/2 ticks in the middle, or every specific values. You can set ax.XTick = -1000:1000 and it'll only show the relevant numbers 😉 For the first thing, it's just ax.XTick = ax.XLim :)
@subhranilbarman45382 ай бұрын
Thanks for the information... very helpful
@coolabahwoodworking Жыл бұрын
That's a gerat video Amazing!
@PhysicsLaure Жыл бұрын
Oh thanks 🧡🧡🧡
@AhmetFrk3472 жыл бұрын
Thank you for sharing this. Such a great code!
@PhysicsLaure2 жыл бұрын
You welcome :)
@venkatprasadpadhy1656 Жыл бұрын
Thank you for the nice explanation, but you have not discussed about removing the whitespaces around the plot, can you please...
@emrahyalcin3 жыл бұрын
it was a very informative video. thanks for sharing. I'll wait for more tips.
@LaureMBrussolo3 жыл бұрын
Thanks ^^
@QED.2 жыл бұрын
Thanks for explanation, it couldn't be better!
@PhysicsLaure2 жыл бұрын
Aww 🥰
@youngwoosim2096 Жыл бұрын
really nice!!! would you share your tips on legends and especially color schemes? how do you manage those?
@SSoIo2 жыл бұрын
Excellent video and code, thank you for sharing :) Was just wondering if we would need to reference you in some way for using the code and if so, how?
@PhysicsLaure2 жыл бұрын
You can quote PhysicsLaure if you'd like but otherwise feel free to use the code. I'm team OpenSource on that kind of things 💚
@SSoIo2 жыл бұрын
@@PhysicsLaure Wonderful, thanks again ❤
@farhazexplains Жыл бұрын
Can you please help me how you create your videos? I really like the style.
@ScuffedF1 Жыл бұрын
Hiya, I've got some questions as I am having issues implementing your code. Taking 1:08 as a screenshot, your code is split into two parts. For the part of the code "Picturewidth..." and below, do I need to copy this after every single figure I create on MATLAB or can I include it at the bottom of my document and be done with it? It would be cool if you could share a document showing the implementation of your code within a MATLAB livescript rather than in isolation (to made it idiot proof haha). Appreciate the work Ciao
@MostafaMASLOUHI9 ай бұрын
Thank you very much. Great work. it would be very nice if you can make a tutorial on legends and color schemes.
@Cuneytege19752 жыл бұрын
Thanks for the tutorial.
@experimentariumciencia2 жыл бұрын
Thank You for this great video. Ivan Experimentarium Brazil
@PhysicsLaure2 жыл бұрын
Hi Ivan! Thanks for watching :)
@shane33793 жыл бұрын
Excellent video, very informative and really well made!
@PhysicsLaure2 жыл бұрын
Hi Shane! Thanks :D
@Axelfotze2 жыл бұрын
Thank you so much for sharing this! This is great! I however like to crop the PDF so there will be no white borders. I just replaced :"print(hfig,fname,'-dpdf','-painters','-fillpage')" with "exportgraphics(hfig, strcat(fname,'.pdf'), 'ContentType', 'vector');"
@PhysicsLaure2 жыл бұрын
Hi Haroun! I didn't know about that function!! Cool ^^
@helderfn Жыл бұрын
Is there a way to do this in Octave? I need to remove the withe borders too.
@marce-work11 ай бұрын
Wow! you are amazing for sharing these secrets with us
10 ай бұрын
I have the same question about legend, have you found a solution? :)
@VisualVEN0M2 жыл бұрын
Amazing video
@PhysicsLaure2 жыл бұрын
Thanks! ^^
@jrgenmyklebust51572 жыл бұрын
can you share the color vectors you are using? great vid!
@PhysicsLaure2 жыл бұрын
Hey! I copy pasted the colormapa developed for matplotlib (magma & co) as they are very pretty :)
@carlosstevensanchezrincon47835 ай бұрын
@@PhysicsLaure could you show how to do that?
@williamnguyen13125 ай бұрын
Life saver, better than chatGPT
@gauravmediratta2926 Жыл бұрын
Would you be able to make a tutorial/ share code on how to create a good legend?
@oleskarjsok9392 Жыл бұрын
Do you have a good way of setting up the colorbar text?
@ehsannavvabi62842 жыл бұрын
Nice Work 🤯🤯🤯🤯
@christiancahig22692 жыл бұрын
Is it possible to have an object-oriented way of handling figures and axes?
@PhysicsLaure2 жыл бұрын
You can have arrays of handle yes. I did it a couple times. Something like listaxes{i} = axes(...);
@rahulaggarwal08 Жыл бұрын
Hi! Thank you so much for a great tutorial! I had been looking for something exactly like this. Just one question- when I print figures using your code, the whitespace/margins around the actual plot are too wide. So when I embed the figure in any document, the actual plot looks smaller. Is there a fix for this?
@mathijslemmens9727 Жыл бұрын
Thank you for your advice. My plots look way better this way. However, when I try to save each figure as a PDF file, I run into a problem. The PDF that is saved only displays a small area of the total plot. I tried to experiment with different width and hw-ratios, but it did not work
@40NoNameFound-100-years-ago2 жыл бұрын
Hello, Thanks for such a great video. I have a question regarding the output pdf file. Now, In case I am writing a research paper and the paper has two columns, suppose I will place the pdf image in one of the columns and not in the middle of the paper, what is the suitable width I should choose for the pdf file when I use : \includegraphics[width=??]{filename.filetype}.....thanks again
@PhysicsLaure2 жыл бұрын
Hi Mohamed! I'd recommemd you manually try it out to see. I usually keep the width at 0.6 and adapt the fontsize until I'm happy with how it fits in the paper. The cool thing is that you can do it on any figure, and it'll work for all :)
@henriquethetraiN Жыл бұрын
@@PhysicsLaure How to save each graphic element separately in png?
@freemanmeno27092 жыл бұрын
Great content! I tried running it in a FOR loop but I get errors on the figure handles. I created a list of figure handles a I let hfig go through the list but it only works for the first element of my list.
@PhysicsLaure2 жыл бұрын
Hey! I don't have the code on hand by arrays of figures are difficult. from memory I stored it in a cell array, and write: myaxis{i} = figure; Hope you find your problem!
@freemanmeno27092 жыл бұрын
@@PhysicsLaure thanks! I will try it out
@filipe.tavares2 жыл бұрын
Hi, Thank you for the tutorial! I really appreciate it!! By the way, what is the editor you use for Matlab scripts? And what is this color scheme and font style? It looks amazing
@PhysicsLaure2 жыл бұрын
Happy you like it Filipe! I made the text in the ideo editor itself. I use one of the dark theme Monokai (my favourite) 😉
@josetjaw8161 Жыл бұрын
I use matlab in vscode just to be able to use theme. And monokai is one of my fav theme too! 😁
@mustaphamustapha38812 жыл бұрын
Thanks, good job
@PhysicsLaure2 жыл бұрын
Thanks ! ^^
@jamesengstrom40982 жыл бұрын
I need pretty colours for my legends and colour schemes pls
@PhysicsLaure2 жыл бұрын
I'm a fan of matlplotlib's colorscheme. You can "steal" them if you can get the array of 3D value. Copy-paste it in excel or directly in Matlab, and you have a new colorscheme :)
@tannguyentrong11426 ай бұрын
thank youuuuuuuuuuuuu so muchh
@henriquethetraiN Жыл бұрын
How to save each graphic element separately in png?
@hahaxd9497 Жыл бұрын
I always get the Error after copypasting the code: Error using matlab.graphics.internal.name (line 101) Cannot create output file '.\myfigure.png'. Error in print (line 71) pj = matlab.graphics.internal.name( pj ); Error in Graphenfürmodulation (line 71) print(hfig,fname,'-dpng','-painters')
@PhysicsLaure Жыл бұрын
Hey! Try without the ".\" in the print command. Otherwise you might not have the rights to create a new file 🤔
@hahaxd9497 Жыл бұрын
Ah thank you! Now it works
@sidchen56953 жыл бұрын
Thanks,helps a lot!
@LaureMBrussolo3 жыл бұрын
Yay ^^
@hishan.farfan Жыл бұрын
Thank you so much!
@PhysicsLaure Жыл бұрын
😊
@waseemshameer3275 Жыл бұрын
What to do if i have multiple figures in the same figure? Also with picturewidth = 20, the figure is shifted to the right a lot in my Latex document
@PhysicsLaure Жыл бұрын
It's shifted to the right bc 20 is too wide for your document. Decrease it til you like it. For the several figures it works just as normal but you need to learn how to manage them (an entire topic in itself 😂)
@waseemshameer3275 Жыл бұрын
@@PhysicsLaure Thank you for the reply, what are the margins you use on your documents?
@PhysicsLaure Жыл бұрын
@@waseemshameer3275 the ones in the video 😅
@kingsoz33722 жыл бұрын
How do you include the legend with the proposed matlab code in the video? Thanks
@PhysicsLaure2 жыл бұрын
You use DisplayName when you plot to set the label of each legend entry, then simply lg=legend('show');
@codeparity2 жыл бұрын
how do you add space between the labels and the axis
@PhysicsLaure2 жыл бұрын
You can set the position of each label, I'd typically do mylabel.Position(x) = mylabel.Position(x)+0.1
@shtrafnoy Жыл бұрын
We're still waiting your tutorial on legends and color schemes?🙃
@PhysicsLaure Жыл бұрын
Haha! I might do it but I need to use my old computer that has matlab 😂
@heictorcosta42428 ай бұрын
@@PhysicsLaure We will be waiting
@yazanmostafa68132 жыл бұрын
How do I add a straight line that belongs to some curved points It ends at x=0
@PhysicsLaure2 жыл бұрын
Hi ! plot([0, x], [o, y],'-')
@shayanroohbakhsh93212 жыл бұрын
cool
@PhysicsLaure2 жыл бұрын
Thanks Shayan! ^^
@dr.imrankhanyousufzai47102 жыл бұрын
I'm unable to make the labels and ticks "bold" using your code. Can you please guide
@PhysicsLaure2 жыл бұрын
Off the top of my head, you can set boldness with the FontWeight parameters (copy paste the line setting the font for everything, and try using it with fontweight". 🤔
@dr.imrankhanyousufzai47102 жыл бұрын
@@PhysicsLaure Thanks for the reply. Actually I tried "FontWeight",'b'. but its not working with the current code. If interpreter is not set to 'latex' then it work.
@jerichocz8079 Жыл бұрын
Love u
@tilkesh Жыл бұрын
thx
@TrymArveLundGabrielsen Жыл бұрын
Great stuff. I made it into a nice function that I have in my 'general ' library if anyone's interested (it uses "exportgraphics" instead of "print", which I find much nicer): function printfigure(filename,options) % Code taken from youtube video: % "kzbin.info/www/bejne/rYGWm52hZrRkbqM" % by PhysicsLaure. arguments filename options.columntype string {ismember(options.columntype,["single","double"])} = "single"; options.fig = gcf; options.hw_ratio double {mustBePositive} = 0.65; options.fontsize double {mustBePositive} = 10; options.filetype string {ismember(options.filetype,["pdf","png"])} = "pdf"; end hfig = options.fig; hw_ratio = options.hw_ratio; % feel free to play with this ratio fontsize = options.fontsize; % adjust fontsize to your document if options.columntype == "single" picturewidth = 15; % set this parameter and keep it forever for continuity in your work elseif options.columntype == "double" picturewidth = 9; % set this parameter and keep it forever for continuity in your work else error('invalid columntype.') end set(findall(hfig,'-property','FontSize'),'FontSize',fontsize) set(findall(hfig,'-property','Box'),'Box','off') % optional set(findall(hfig,'-property','Interpreter'),'Interpreter','latex') set(findall(hfig,'-property','TickLabelInterpreter'),'TickLabelInterpreter','latex') set(hfig,'Units','centimeters','Position',[3 3 picturewidth hw_ratio*picturewidth]) pos = get(hfig,'Position'); set(hfig,'PaperPositionMode','Auto','PaperUnits','centimeters','PaperSize',[pos(3), pos(4)]) if options.filetype == "pdf" exportgraphics(hfig,[char(filename),'.pdf'],'ContentType','vector') elseif options.filetype == "png" exportgraphics(hfig,[char(filename),'.png'],'ContentType','image') else error('Invalid filetype.') end end