matlab-figure

One combined legend entry for multiple plots

时间秒杀一切 提交于 2019-12-18 09:33:53
问题 For some reason, I would like to plot the line and marker of the same data separately. data1 = (1:1:10)'; data2 = (1:2:10); figure(1); plot(data1,data1,'or'); hold on; plot(data2,data2,'-r'); legend('data'); However it will only display the legend for the first plot. And Matlab seems not to have option to manipulate the legend marker, color and linestyle. How can I make legend like this? Thanks! 回答1: You will need to plot an invisible third plot (with almost no data to keep it fast) to define

Running a GUI requires opening the .fig file in GUIDE

若如初见. 提交于 2019-12-18 07:08:16
问题 I am trying to run a MATLAB GUI I have created. If I open the .fig file using GUIDE and press the run button there, it runs perfectly. However, when I double-click the .fig file in the 'Current Folder' section of MATLAB, it seems to be unable to find the handles variable. This causes it to give an error whenever handles is used. Why does this happen? Is there a fix/workaround? I'm using MATLAB R2011, but I've tried it on R2012 as well. The code runs fine, and displays the GUI fine, but the

Putting certain tick labels in boldface (but not all of them)?

纵饮孤独 提交于 2019-12-18 06:18:35
问题 In MATLAB I have a graph with some tick labels. I'd like to visually emphasize a few of these labels, but not all of them. Is there a way to only put SOME tick labels in boldface? 回答1: You could also overlay your "original" axis with a second one. On the second you configure the ticks bold. Together with linkaxes you maintain proper zoom behavior. 回答2: Though I can't tell if it wasn't possible in the past, but nowadays (at least from R2014b) one could just use tex markup: plot(0:10,0:10); h =

Greek letters in axes labels are not working

橙三吉。 提交于 2019-12-18 04:26:14
问题 I'm trying to use Greek letters in my xlabel of a plot. Every solution on the internet says that Matlab will accept tex. But instead of the delta-symbol my x-axis is simply labeled 'D' a = plot(0:40, y); hold on plot(delta_T,brechkraft, 'x') errorbar(delta_T, brechkraft,delta_b,'x'); title('2mm Oelschicht'); xlabel('\Delta'); ylabel('Brechkraft D in 1/cm'); annotation('textbox', [.2 .8 .1 .1],... 'String', {'Fit: f(x) = m*x + b', ['m = ', num2str(p(1)) ], ['b = ', num2str(p(2)) ]}); shg hold

How to export non-blurry eps images?

佐手、 提交于 2019-12-18 02:22:18
问题 I'm exporting an image in Matlab using the eps format, but it smooths the image. Matlab does not blur the image using other formats such as png. I would like to know how to export a non-blurry image with eps format. Here is the resulting image using png: And here is the resulting image using eps: 回答1: UPDATE: The problem is reproducible on a Mac, and the issue is with the eps renderer rather than MATLAB. For e.g., saving imagesc(rand(20)) and viewing with Preview and GSview results in the

How to export non-blurry eps images?

拥有回忆 提交于 2019-12-18 02:22:09
问题 I'm exporting an image in Matlab using the eps format, but it smooths the image. Matlab does not blur the image using other formats such as png. I would like to know how to export a non-blurry image with eps format. Here is the resulting image using png: And here is the resulting image using eps: 回答1: UPDATE: The problem is reproducible on a Mac, and the issue is with the eps renderer rather than MATLAB. For e.g., saving imagesc(rand(20)) and viewing with Preview and GSview results in the

How to use polar axes with Matlab warp?

耗尽温柔 提交于 2019-12-17 20:42:52
问题 I want to use polaraxes on the warp object on the half circumference of the polar presentation. Code without polaraxes but with warp close all; clear all; clc; % https://stackoverflow.com/a/7586650/54964 load clown; img = ind2rgb(X,map); [h,w,~] = size(img); s = min(h,w)/2; [rho,theta] = meshgrid(linspace(0,s-1,s), linspace(0,pi)); [x,y] = pol2cart(theta, rho); z = zeros(size(x)); f1=figure(); hax=axes('Parent', f1); imagesc(img, 'Parent', hax); box(hax, 'off'); axis(hax, 'off'); set(hax,

How to imshow with Invisible figure in MATLAB running on Linux

时光毁灭记忆、已成空白 提交于 2019-12-17 19:30:35
问题 My goal is to: Create an invisible figure Using subplots, plot images on it, and then Save it without having it to open. Thus, I am running the following code: f = figure('Visible', 'off'); subplot(2, 2, 1), imshow(image1); subplot(2, 2, 2), imshow(image2); subplot(2, 2, 3), imshow(image3); subplot(2, 2, 4), imshow(image4); saveas(f, 'filename'); But I get the error: Error using imshow (line xxx) IMSHOW unable to display image. This means that imshow is trying to display image. Is there a way

How to change image axis labels

柔情痞子 提交于 2019-12-17 19:02:20
问题 I'm trying to change the image axis labels with some latitude/longitude but I can't find how to do it. I tried some basic commands like: imagesc(data) axis(meshgrid([-180:20:180],[-90:20:90])) colorbar but these expression appeared: imagesc(data),axis(meshgrid([-180:20:180],[-90:20:90])), colorbar Operands to the || and && operators must be convertible to logical scalar values. Error in axis>allAxes (line 448) result = all(ishghandle(h)) && ... Error in axis (line 57) if ~isempty(varargin) &&

Remove only axis lines without affecting ticks and tick labels

冷暖自知 提交于 2019-12-17 18:31:39
问题 Is there a way to remove only the axis lines in the Matlab figure, without affecting ticks and tick labels. I know that box toggles the upper and right axes lines and ticks and that works perfectly for me. But my problem is that I want eliminate the bottom and left lines (only lines!) but keeping the ticks and tick labels. Any tricks? 回答1: There is another undocumented way (applicable to MATLAB R2014b and later versions) of removing the lines by changing the 'LineStyle' of rulers to 'none' .