matlab-figure

Moving MATLAB axis ticks by a half step

为君一笑 提交于 2019-12-06 05:09:47
问题 I'm trying to position MATLAB's ticks to line up with my grid, but I can't find a good way to offset the labels. Also, if I run set(gca,'XTickLabel',1:10) , my x tick labels end up ranging from 1 to 5. What gives? 回答1: You need to move the ticks, but get the labels before and write them back after moving: f = figure(1) X = randi(10,10,10); surf(X) view(0,90) ax = gca; XTick = get(ax, 'XTick') XTickLabel = get(ax, 'XTickLabel') set(ax,'XTick',XTick+0.5) set(ax,'XTickLabel',XTickLabel) YTick =

Drawing 3-D RGB cube model with Matlab

感情迁移 提交于 2019-12-06 02:58:56
问题 I wrote this code to draw an RGB cube, but it's color not exact as true? %Define a six row by four column matrix to define the six cube faces fm = [1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8] %Define an eight row by three column matrix to define the vertices at which %the faces meet vm = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1] %Plot the cube ----- gives each face a different color and creates the cube at a convenient viewing angle patch('Vertices',vm,'Faces',fm,

Matlab updating subplots and hold on

拟墨画扇 提交于 2019-12-06 00:20:44
I am having trouble with updating subplots. I've boiled my problem down to the following example: win = figure(1); win.sub1 = subplot(2, 2, 1); win.sub2 = subplot(2, 2, 2); win.sub3 = subplot(2, 2, 3); win.sub4 = subplot(2, 2, 4); x = 1:1:10; plot(win.sub2, x, x); %graphs the line y = x in the second subplot, good. hold on; plot(win.sub2, x, -x) %ought to plot line y = -x over line y = x, but does not. When executing the second plot, the first plot disappears despite the hold on. The only thing that seems to make this work is if I use axes(win.sub2), but I'm trying to avoid that because it

MATLAB simple slider on a figure

亡梦爱人 提交于 2019-12-05 22:44:42
I have a matrix to be plotted one column at a time. Is it possible to add a slider to a MATLAB figure (without heavy GUI programming) so that by moving the slider, different columns are shown in the current axis? Here is a code for a slider to plot corresponding column: m = ones(5,1)*(1:5); slmin = 1; slmax = size(m,2); plot(m(:,1)) hsl = uicontrol('Style','slider','Min',slmin,'Max',slmax,... 'SliderStep',[1 1]./(slmax-slmin),'Value',1,... 'Position',[20 20 200 20]); set(hsl,'Callback',@(hObject,eventdata) plot(m(:,round(get(hObject,'Value')))) ) EDIT : For better performance you can just

How can I convert an RGB histogram into a color spectrum?

只谈情不闲聊 提交于 2019-12-05 22:13:08
How can I convert an RGB histogram of an image to create a histogram showing the combined colors along with correct color wavelength range? Example code: pkg load image f=imread('/tmp/marbles.jpg'); f=uint8(f); %need to convert back to uint8 to show picture %Split into RGB Channels f_red = f(:,:,1); f_green = f(:,:,2); f_blue = f(:,:,3); %Get histValues for each channel [y_f_red, x] = imhist(f_red); [y_f_green, x] = imhist(f_green); [y_f_blue, x] = imhist(f_blue); subplot (2,1,1); imshow(f); subplot (2,1,2); plot(x, y_f_red, 'r', x, y_f_green, 'g', x, y_f_blue, 'b'); Example image along with

How to prevent the fill command in MATLAB from creating boxes without “corners”

早过忘川 提交于 2019-12-05 19:49:27
I am currently using the fill command in MATLAB to create a graph of boxes that were created using the 'fill' command (the actual code is based off this StackOverflow Question . My issue is that the boxes that I create do not have "corners." I am attaching a PNG that illustrates the issue. Note that you have to look a little carefully since the image was heavily rendered, though in this example my arrows also look weird since they don't have edges either) I am wondering if anyone has an idea of what might be going wrong? The boxes appear this way immediately after I use the fill command, which

Changing figure fonts in Matlab has no effect

不问归期 提交于 2019-12-05 19:46:19
问题 I'm having problems with rendering Greek characters in my labels and legends, so I thought maybe switching fonts would help. Thus, I discovered an even bigger problem - Matlab doesn't seem to honor my font settings at all. I've tried, of course, set(gcf, 'FontName', 'Ubuntu') set(gca, 'FontName', 'Ubuntu') but also things like set(findall(gca, 'type', 'text'), 'FontName', 'Ubuntu') and set(0,'DefaultAxesFontName', 'Ubuntu') I also tried switching renderers, with set(0, 'DefaultFigureRenderer'

Program to open .fig files saved by Matlab

ε祈祈猫儿з 提交于 2019-12-05 10:27:17
问题 Is there any program able to open .fig files saved by Matlab? 回答1: Update 29/04/2016 According to johnml1135's answer, fig files are essentially just mat files, and johnml1135 figured out where the various plot elements are stored, for converting a fig file to a Python plot. Original According to the answer here the fig file saved by Matlab is in a proprietary binary format. I don't know of any other software capable of loading this format. Your best option is probably to have the figure

How can I fill an area below a 3D graph in MATLAB?

人盡茶涼 提交于 2019-12-05 10:05:57
I created the following 3d plot in MATLAB using the function plot3 : Now, I want to get a hatched area below the "2d sub-graphs" (i.e. below the blue and red curves). Unfortunately, I don't have any idea how to realize that. I would appreciate it very much if somebody had an idea. gnovice You can do this using the function fill3 and referencing this answer for the 2D case to see how you have to add points on the ends of your data vectors to "close" your filled polygons. Although creating a pattern (i.e. hatching) is difficult if not impossible, an alternative is to simply adjust the alpha

How can I change 'PlotStyle' property of a given boxplot figure?

那年仲夏 提交于 2019-12-05 08:01:33
Given a .fig file of a Matlab boxplot (i.e. underlying data not available), is it possible to change the PlotStyle attribute (from 'traditional' to 'compact')? This question is kind of tricky because not like other graphic objects in Matlab, boxplot is a group of lines. As so, all the properties that are set while you create it are inaccessible (and in fact does not exist) after plotting. One option to deal with that is to create a 'dummy' boxplot, and then alter it to your data. Because boxplot has no simple properties of XData and YData , at least not as we use to them, it takes some work to