My plot does not perform correctly
for k in range(0,len(j)):
fig = px.scatter(X_reduced_df, x='EXTRACTION_DATE_SAMPLE', y=[j[k]], title = "Größe " + str(k) +": " + j[k],
color= 'anomaly_class_IF', hover_data=['score_IF','delta', 'omicron', 'NH4-N (titr.)(W)_Zusatzparameter-ESRI',
'P ges. filtr. (photom.)(W) mA_Zusatzparameter-ESRI',
'BSB5 (mit Verd) DIN 1899_Zusatzparameter-ESRI',
'N org. (Ber. TKN)(W)_Zusatzparameter-ESRI'
])
fig.show()
the result is
why do i get this? the date is not shown correctly, and as a consequence, the plot is empty.
i tried the plot without the loop and it works just fine. what can i do to fix this?
The spacing on the y axis label get all wrong when printing with print
The code to reproduce the issue is:
data1 = [1:10:100]
data2 = [100:10:200]
file = "plottest.png"
[at ho ht] = plotyy(data1,data1,data2,data2);
ylabel(at(1),"Concentration of O_2 (mol/m^3)");
print(gcf,file);
I'm using the qt graphics tool.
Output to figure window (and also desired result):
What gets printed to PNG file:
One workaround could be using the latex interpreter as
ylabel(at(1),"Concentration of $O_2$ (mol/m^3)", 'Interpreter', 'latex');
This is an extension of How to change display format of legend in MATLAB.
I am looking for a way to force the legend entries in a particular format. In following code, they are displayed like
Instead I want them in power of 10's. Like $10^{-1},10^{-2}$.
Is there a way to do this?
MWE:
sig=[0.1 0.01 0.001 0.0001 0.00001];
for j=1:length(sig)
for x=1:10
Cost(j,x) = 2*x+j;
end
plot(1:10,Cost(j,:));
end
legend(strcat('\sigma^2_n=',num2str((sig)')));
set(h,'Interpreter','latex')
Simply log10 sig in the num2str and prepend the base:
sig=[0.1 0.01 0.001 0.0001 0.00001];
for j=1:length(sig)
for x=1:10
Cost(j,x) = 2*x+j;
end
hold('on');
plot(1:10,Cost(j,:));
end
h=legend(strcat('$\sigma^2_n = 10^{',num2str((log10(sig))'),'}$'));
set(h,'Interpreter','latex','fontsize',16)
hold('off');
I have designed the following GUI in which there are an axes. I want to save the plot drawn inside them to a jpeg file. However, the file obtained is an image of the overall figure window. This is my code:
X = 0:pi/100:2*pi;
Y = sin(X);
fh = figure;
Pan1 = uipanel(fh,'Units','normalized','Position',[0 0 0.5 1],'title',...
'Panel1');
Pan2 = uipanel(fh,'Units','normalized','Position',[0.5 0 0.5 1],'title',...
'Panel2');
haxes = axes('Parent',Pan2,'Units', 'normalized','Position',...
[0.25 0.25 0.5 0.5]);
hplot = plot(haxes,X,Y);
xlabel(haxes,'Time (second)');
ylabel(haxes,'Amplitude (meter)');
title(haxes,'Sine function');
FileName = uiputfile('*.jpg','Save as');
saveas(hplot,FileName);
saveas only saves figures, not individual plots.
If you have a subplot, or a plot within a uicontrol like you have, you can make a temporary copy of the plot, save it, then delete the temporary copy:
ftmp = figure; atmp = axes;
copyobj(hplot, atmp);
saveas(ftmp, FileName);
delete(ftmp);
If you don't want the temporary copy to flash up on the screen during the copying step, you can use the 'Position' property of the figure to create it off-screen.
Hope that helps!
#Sam's answer is spot on, I just want to add that Matlab is smart enough to know what kind of file you want to save by inspecting the FileName string variable. If you set FileName to something that ends in .jpg, you can save a jpeg. Check out the saves docs to see all the other possible filetypes.
When using the saveas function to create jpeg the resolution is different as when manually saving the figure with File-->Save As..., It's more recommended to use hgexport instead, as follows:
hgexport(gcf, 'figure1.jpg', hgexport('factorystyle'), 'Format', 'jpeg');
This will do exactly as manually saving the figure.
source:
http://www.mathworks.com/support/solutions/en/data/1-1PT49C/index.html?product=SL&solution=1-1PT49C
This is my solution based on Sam Roberts and eykanal's answer:
X = 0:pi/100:2*pi;
Y = sin(X);
fh = figure('toolbar','none','menubar','none');
Pan1 = uipanel(fh,'Units','normalized','Position',[0 0 0.5 1],'title',...
'Panel1');
Pan2 = uipanel(fh,'Units','normalized','Position',[0.5 0 0.5 1],'title',...
'Panel2');
haxes = axes('Parent',Pan2,'Units', 'normalized','Position',...
[0.125 0.1 0.75 0.75]);
hplot = plot(haxes,X,Y);
xlabel(haxes,'Time (second)');
ylabel(haxes,'Amplitude (meter)');
title(haxes,'Sine function');
FileName = uiputfile('*.bmp;*.png;*.jpg;*.tif','Save as');
ftmp = figure('Menu','none','Toolbar','none','Units','normalized',...
'Position',[-1000 -1000 1 1]);
new_axes = copyobj(haxes, ftmp);
set(new_axes,'Units','normalized','Position',[0.1 0.1 0.8 0.8]);
saveas(ftmp, FileName);
delete(ftmp);
delete(fh);
Hey, I have a skinned mesh that animates over time.
I'm writing a quick export script to export out my verticies.
How do I output the vertices per frame?
I'm getting the verticies using getVert, but how do I specify which frame to get the vertex from?
Thanks
ASH
The following code is untested, but something like it should work for you. Please let me know if there are any changes you need to make.
/* Exports mesh data 'm' to file 'f' */
def exportData m f = (
format "%,%\n" m.numverts m.numfaces to:f
for i = 1 to m.numverts do
format "%," (getVert m i) to:f
format "\n" to:f
for i = 1 to m.numfaces do
format "%," (getFace m i) to:f
)
/* Exports mesh data from a node 'n' at time 't' to file 'f' */
def exportNodeMeshAtTime t n f =
(
at time t
m = snapshotAsMesh n
exportMesh m f
)
/* Create a text file for receiving the data */
out_file = createfile ((GetDir #export)+"/testmesh.dat")
/* Enumerate all times in the animation range, exporting
the mesh data from the selected node at time t. */
for t = animationRange.start to animationRange.end do (
exportNodeMeshAtTime t selection[1] out_file
)
/* Close the text file */
close out_file
you can use "at time" for the whole mesh.
e.g. "at time i mmesh=snapshotAsMesh obj"
where "i" is the frame you want, "obj" the existing object and "mmesh" the resulting mesh.
on mmesh you can do your usual getvert functions.