figure(1);
set(gcf, 'Visible', 'off');
plot(x, y);
print(gcf, '-dpdf', 'figure1.pdf');
system('open -a Texshop figure1.pdf');
[robg adds: I can't test this one; if you can verify that it works, please post a comment.]
|
|
|
Matlab on OS X uses X11 to generate plots. These plots often have jagged lines, and are not rendered as smoothly as a PDF exported version of the same plot. With Octave, one can use the Aquaterm plotting front-end, but there seems to be no way to do that with Matlab. The following example piece of Matlab code makes Matlab convert a figure to PDF and display it in TeXShop, which auto-refreshes the PDF (unlike Preview):
[robg adds: I can't test this one; if you can verify that it works, please post a comment.]
•
[11,374 views]
Hint Options
Use TeXShop instead of X11 for Matlab plots
Nice hint, plot looks much smoother than the default X11 plot in matlab.
Use TeXShop instead of X11 for Matlab plots
Indeed... works fine.
Use TeXShop instead of X11 for Matlab plots
If you don't need to refresh the figure, Preview loads up dramatically faster (at least on my new powerbook).
Use TeXShop instead of X11 for Matlab plots
Well..hmm. It did the first time. Now they seem about the same.
MatLab X11 plots are interactive
This is OK if the plot that you are generating is your final product, but you give up the interactive behavior of the MatLab X11 GUI plot interface, where you can change plot parameters by clicking on them. Furthermore, you can save plots to many formats, including PDF, from the X11 interface. Another file format available in MatLab is the MatLab figure file (.fig), which allows you to open a saved plot and reconfigure plot ranges, axis labels, etc. and even export to other file formats without regenerating the plot from your original data.
MatLab X11 plots are interactive
I agree this is only relatively useful, but it points towards the ability to better interface Matlab and OS X. These things can be wrapped into an m-file to increase the usability. I previously wrote the following function to help me compare two m-files. I thought others might find it useful.
MatLab X11 plots are interactive
What about a :
auto-refresh ?
Indeed, the hint works fine. However, what do you mean by "auto-refreshes" exactly ? After the figure is in TexShop, if you modify it in Matlab (like putting a title, or scale units), it doesn't change in TexShop, you have to re-export the plot.
auto-refresh ?
I think they mean that when you re-export the PDF, TexShop recognizes the file changed and then updates its display without you having to reload the PDF in TexShop.
auto-refresh ?
Yes, you need to re-export the figure with the print command, but then that line doesn't change, so if it pasted after the plot command, the PDF file is always current, and is then refreshed by TeXShop. As you said, the hint is nothing more than a way to print the figure to PDF and open it with a suitable viewer - I only wanted to emulate the similar behavior I was getting with Octave and Aquaterm.
Auto-refresh does not work for me
Just to let you know, I have to close the pdf file (in both cases using either Texshop or Preview) before I run the Matlab script again, otherwise it does not get updated, although the still-open pdf file is brought back in the foreground, creating the impression that it has been newly created and causing much agony on my side wondering why the hell Matlab is not adhering to any commands about the position of the figure on the page.
Auto-refresh does not work for me
i can judge this even better from the pride that sounds through in your last comment. ha! erwischt.
Use TeXShop instead of X11 for Matlab plots
Skim is probably a better alternative now. It also autorefreshes from disk. It uses kqueue to do these updates, so they are event-based rather than updates resulting from polling the disk periodically. This is clearly a good way to do things, but the downside is that if the file gets deleted, updates will cease to be sent (e.g., what happens with simpdftex that can be easily fixed). Regardless, it has lots of other great features. The author of the discontinued PDFView suggests that people use it instead. I think it will become the dominant PDF viewer in OS X. Because it's simply a PDF viewer, it seems more appropriate (and probably opens faster) than using TeXShop for MATLAB previews. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.17 seconds |
|