Save listener Callback in eps format or any high resolution format

조회 수: 1 (최근 30일)
Hello,
for the Cart-Pole example and Training result (Episode Reward Chart) in RL Toolbox I am getting a static figure, that I can't save in anyway other than with the snipping tool which ruins the quality. I also tried to use the saveas command like here, but the eps or png file is coming empty and a figure 2 is opening.
Any help is much appreciated!
  댓글 수: 6
Rik
Rik 2021년 3월 29일
You might need to use some tricks to get to the figure handle. The example below shows how you could try. I don't have the required toolboxes, so it is hard for me to experiment.
env = rlPredefinedEnv("CartPole-Discrete");
x=plot(env);
fig = getHiddenProp(x,'Figure');
saveas(fig, 'png_saved','png')
%confirm saving worked:
I=imread('png_saved.png');
figure,imshow(I)
function varargout=getHiddenProp(obj,PropType)
% Retrieve a hidden property from an object
% Use with care, this maight break for any release.
% If there are multiple objects, the first will be selected.
% If there are multiple matches, they will be returned in multiple outputs.
w=warning('off','all');
x=struct(obj);
warning(w);
if numel(x)>1,x=x(1);end
if numel(x)<1,varargout={};return,end
fn=fieldnames(x);
y=cellfun(@(elem) ...
ismember(cellstr(PropType),...
regexprep(class(x.(elem)),'.*\.','')... strip matlab.graphics.axis.Axes to Axes etc
),fn);
varargout=fn(y);
for n=1:numel(varargout)
varargout{n}=x.(varargout{n});
end
end
Reinforcement Learning
Reinforcement Learning 2021년 4월 1일
편집: Reinforcement Learning 2021년 4월 1일
@Rik I tried that and it worked. But the .eps file isn't really so clear. If I include that in my pdf, it's pixelated for some reason. Of course I changed the format from png to epsc

댓글을 달려면 로그인하십시오.

채택된 답변

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2021년 3월 29일
Hello,
If you are using R2020b, you can use
help rlPlotTrainingResults
to recreate the Episode manager plot and save it as you need.
If you are using R2021a, this function is now renamed to "inspectTrainingResult".
Hope that helps
  댓글 수: 1
Reinforcement Learning
Reinforcement Learning 2021년 3월 29일
I am using R2020b. Do you mean like this? I already mentioned this in the comments, it only lets me save it as .pdf or .png. The bigger issue is with the Cart-Pole Visulaizer. It doesn't seem, like I can save that in any way

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by