Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Enlarge figure in MATLAB

  1. Oct 22, 2015 #1

    kelvin490

    User Avatar
    Gold Member

    I want to create figure that is enlarged, I use:

    fig = figure(1);%These two lines maximize the figure dialogue
    set(fig,'Units','normalized','Position',[0,0,1,1]);

    Then I use zoom(1.9); to enlarge the figure

    The dialogue is enlarged. But I want to reposition it just like use the "pan" button. How can I do it programmatically?
     
  2. jcsd
  3. Oct 22, 2015 #2
    Most new versions of Matlab can generate a script for button function.
     
  4. Oct 22, 2015 #3

    kreil

    User Avatar
    Gold Member

  5. Oct 23, 2015 #4

    kelvin490

    User Avatar
    Gold Member

    Actually my problem is still not solved.
    Here's update of my question:
    I am trying to plot 3D block which the value is represented by color of each small unit block:

    clear; close all; clc;
    fig = figure(1);
    set (fig, 'Units', 'normalized', 'Position', [0,0,1,1]);
    fig_color='w'; fig_colordef='white';
    cMap=jet(256); %set the colomap using the "jet" scale
    faceAlpha1=1;
    faceAlpha2=0.65;
    edgeColor1='none';
    edgeColor2='none';
    NumBoxX=100;%box number in x direction
    NumBoxY=100;%box number in y direction
    NumBoxZ=5;%box number in z direction

    fid = fopen('Stress.dat','r');
    datacell = textscan(fid, '%f%f%f%f%f%f%f%f%f%f%f%f%f%f');
    fclose(fid);

    all_data = cell2mat(datacell);

    M=zeros(NumBoxX,NumBoxY,NumBoxZ);

    for i=1:NumBoxX
    for j=1:NumBoxY
    for k=1:NumBoxZ
    num=k+NumBoxZ*(j-1)+NumBoxZ*NumBoxY*(i-1);
    M(i,j,k)=all_data(num,4); %the forth column of all_data is dislocation density
    end
    end
    end

    indPatch=1:numel(M);
    [F,V,C]=ind2patch(indPatch,M,'v'); %Call the function ind2patch in order to plot 3D cube with color

    title('\sigma_{xy}','fontsize',20);
    xlabel('y','fontsize',20);ylabel('x','fontsize',20); zlabel('z','fontsize',20); hold on;
    set(get(gca,'xlabel'),'Position',[5 -50 30]);
    set(get(gca,'ylabel'),'Position',[5 50 -15]);
    set(get(gca,'zlabel'),'Position',[64 190 -60]);
    patch('Faces',F,'Vertices',V,'FaceColor','flat','CData',C,'EdgeColor','k','FaceAlpha',0.5);
    axis equal; view(3); axis tight; axis vis3d; grid off;
    colormap(cMap); caxis([min(M(:)) max(M(:))]);
    cb = colorbar;
    set(get(cb,'title'),'string','Stress (MPa)','fontsize',20);
    lbpos = get(cb,'title'); % get the handle of the colorbar title
    set(lbpos,'units','normalized','position',[0,1.04]);
    zoom(1.9);

    I maximize the dialogue, read data from a file and use a function "ind2patch" found in internet to create boxes each has a color determined by a value assigned to it. At the last part I used zoom(1.9) to enlarge it but I want to shift the whole figure without moving the colorbar.
    The following is the original picture before zoomed:
    https://www.dropbox.com/s/xashny3w1fwcb2f/small.jpg?dl=0

    The following picture is enlarged using zoom(1.9):
    https://www.dropbox.com/s/0sfqq1lgo7cm5jd/large.jpg?dl=0
     
  6. Oct 23, 2015 #5

    kreil

    User Avatar
    Gold Member

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Enlarge figure in MATLAB
  1. MATLAB figure in LATEX (Replies: 5)

Loading...