xLabelTick and Save graph button
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear all, I have got a GUI for plotting from an *.xls file, and I want to have a save button which will save the plot and its legend to an *.eps file with a resolution of 600 dpi. Please, help me to do this. And, one more thing, on x axis labels are shown in a format of 'HH:MM', how can I make it just in minutes? Here is my m-code:
function viewSTUEP
global hPlot hChoice raw
handles.F = figure('Name','viewSTUEP', 'Position',[100 20 900 520], ...
'Color',[0.8 0.8 0.8], 'NumberTitle','off', 'Resize','off');
uicontrol('Style','pushbutton', 'Position',[690 480 64 30], ...
'FontSize',12, 'String','Load', 'Callback',@LoadData);
uicontrol('Style', 'pushbutton', 'Position', [760 480 64 30], ...
'FontSize',12, 'String','Update', 'Callback',@UpdatePlot);
uicontrol('Style','pushbutton', 'Position',[830 480 64 30], ...
'FontSize',12, 'String','Close', 'Callback',{@Close,handles});
set(handles.F, 'CloseRequestFcn', {@Close,handles})
set(gcf, 'Toolbar', 'figure');
clear raw, raw(1,:) = {''};
hPlot = axes('Position',[0.05 0.05 0.7 0.93], 'Visible','on');
uicontrol('Style','text', 'Position',[690 432 130 35], ...
'BackgroundColor',[0.8 0.8 0.8], 'FontSize',12, ...
'HorizontalAlignment','left', 'String','Columns for plot:');
hChoice = uicontrol('Style','listbox', 'Position',[690 420 204 22], ...
'FontSize',12, 'String',raw(1,:), 'Min',1, 'Max',1);
function Close(hObject, eventdata, handles)
delete(handles.F)
function LoadData(hObject, eventdata)
global hChoice raw xdat
[fname, pname] = uigetfile('*.xls','Select a data file');
if fname ~= 0
filename = strcat(pname, fname);
[numeric,text,raw] = xlsread(filename);
num = length(raw(1,:));
if (num > 21) num = 21; end
posY = 442 - (20*num);
set(hChoice, 'String',raw(1,:));
set(hChoice, 'Max',num);
set(hChoice, 'Position',[690 posY 204 (20*num)]);
xdat = datenum(0,0,0,0,0,cell2mat(raw(2:end,6)));
end
function UpdatePlot(hObject, eventdata)
global hPlot hChoice raw xdat
if ~isempty(raw)
cols = get(hChoice,'Value');
plot(hPlot, xdat,cell2mat(raw(2:end,cols(1))), 'LineWidth',2), datetick('x','HH:MM')
grid on
if (length(cols) > 1)
colors = 'brgcmyk'; c = 2;
hold(hPlot, 'on')
for k = cols(2:end)
plot(hPlot, xdat,cell2mat(raw(2:end,k)),colors(c),'LineWidth',2)
c = c+1; if (c > 7) c = 1; end
end
hold(hPlot, 'off')
end
legend(hPlot, raw(1,cols), 'Interpreter','none','Location','Best')
end
Thank you!
2 commentaires
Réponses (3)
Arthur
le 21 Août 2012
1. eps is a vector format and thus does not have a resolution.
2. change:
datetick('x','HH:MM')
into:
datetick('x','MM')
0 commentaires
Voir également
Catégories
En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!