xLabelTick and Save graph button

2 visualizzazioni (ultimi 30 giorni)
Dzhamshed
Dzhamshed il 21 Ago 2012
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 Commenti
Azzi Abdelmalek
Azzi Abdelmalek il 21 Ago 2012
what is your question?
Dzhamshed
Dzhamshed il 21 Ago 2012
1. How can I make a save button, which will save a plot with it's legend into an *.eps file with the resolution of 600 dpi? 2. How to change the xLabelTick, in order to show just in format of 'MM' - minutes, but not 'HH:MM'????

Accedi per commentare.

Risposte (3)

Arthur
Arthur il 21 Ago 2012
1. eps is a vector format and thus does not have a resolution.
2. change:
datetick('x','HH:MM')
into:
datetick('x','MM')

Dzhamshed
Dzhamshed il 21 Ago 2012
OK I solved the problem about the save button, and it works well:
function SaveAs(hObject, eventdata, handles)
[Save,savename] = uiputfile('*.eps','Save plot as: ')
fname=fullfile(savename,Save);
print('-depsc','-r300','-noui',fname)
Now I need your help, in order to solve the problem about xLabelTick(((

Dzhamshed
Dzhamshed il 21 Ago 2012
Sorry, but one more thing, how can I add a button, which will be able to update the data from an xls file, something like run/pause update?

Categorie

Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by