フィルターのクリア

xLabelTick and Save graph button

3 ビュー (過去 30 日間)
Dzhamshed
Dzhamshed 2012 年 8 月 21 日
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 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 21 日
what is your question?
Dzhamshed
Dzhamshed 2012 年 8 月 21 日
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'????

サインインしてコメントする。

回答 (3 件)

Arthur
Arthur 2012 年 8 月 21 日
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 2012 年 8 月 21 日
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 2012 年 8 月 21 日
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?

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by