How do you force a figure redraw ipython notebook inline? - ipython

I am using pandas and ipython notebook inline. I drew a figure with pandas dataframe
figure()
subplot = df['likes'].hist()
subplot.set_title("Likes")
display(fig)
draw()
I am trying to add a title to the histogram for example and I'd like to redraw it, but ipython notebook does not redraw.
Does anyone have a suggestion? In ipython when I use draw() it redraws and adds a title. I want to format my pandas plots.

It seems that ipython notebook closes the figure after I execute the cell's code. To format the axes I have to execute all the code in a single cell.

Related

How can I set text orientation in Excel using matlab actxserver?

I'm using matlab actxserver to make a excel table. I want to change the orientation of text in a cell. I have checked some VBA codes. But I don't know how to transform a VBA command in Matlab code. I have tried:
eSheet.Range.Orientation=90;
eSheet.Range.XlOrientation=-4171;
(https://learn.microsoft.com/en-us/office/vba/api/excel.xlorientation)
(https://learn.microsoft.com/en-us/office/vba/api/excel.range.orientation)
They don't work.
What's the correct syntax to do this?

displayHTML in Azure Databricks shows only a small slice of a leaflet map

I'm attempting to display an HTML file (a leaflet map) using displayHTML() inside a notebook. The file is created with the R mapview package, after following https://docs.databricks.com/notebooks/visualizations/htmlwidgets.html to make it all work. The HTML file is valid and I can open it in a browser window with full functionality.
What's happening in the notebook is that in the cell output, the map is only rendering as a very short slice of the map:
The visual appears to be fully functional, but I cannot figure out how to increase the size of the render/display area. I imagine it's either something within the HTML itself (like it's fitting to the size of the pane of the Databricks cell output, which it's thinking is a single line, perhaps), or there's a Databricks setting I'm not seeing. Resizing the cell output with a click-drag on the bottom-right corner has no effect.
Is there a way to make the map take up more space in a cell output?
DBR 9.1 LTS

Why does Matlab set the background white when saving a scope printed to figure?

I want to programmatically 'Print to figure' a Simulink scope and save the resulting figure to a folder.
Consider following Simulink model and select the scope:
I run following code (inspired by this question):
scopeName=get_param(gcb,'Name');
hs=findall(0,'Name',scopeName);
hf=figure(1);
hp=findobj(hs.UserData.Parent,'Tag','VisualizationPanel');
copyobj(hp,hf)
filename='test.tiff';
print('-dtiff',filename);
Although both the scope and the figure have a black background
the saved file has a white background
Is there something wrong with the print command or with something else?
By default, MATLAB inverts the background colors when printing to a figure. To get around this, you can set the InvertHardCopy to 'off'
set(gcf, 'InvertHardCopy', 'off')
Doing this (as opposed to using getframe) results in a much higher resolution image as getframe simply saves the figure at screen resolution (72dpi).
Another option is to use export_fig from the MATLAB file exchange to save the figure which will more reliably reproduce the image that is on your screen.
You can get the same view as you see:
img = getframe(gcf);
imwrite(img.cdata,'test.tiff');

Matlab figure saved as .eps appears in 'horizontal sections' when opened in Adobe Illustrator

I normally save my matlab figures as .eps and then make them better looking using Adobe Illustrator. This works for most figures but not all.
For example I plotted my data using the violin.m function from file exchange. When I save it as .eps and open it in Illustrator, I don't get an editable figure as I usually do. Instead, My figure appears chopped in horizontal sections, and all I can do is delete them (like in the figure below).
Is there anything I can do in either matlab or Illustrator to be able to edit the figure?
I don't need an .eps file, I just need to be able to edit it.
EDITS:
I tried #MattSchmatt's suggestion of using the print2eps function but I had the same problem.
Saving as .pdf doesn't solve the problem, because the image I get is not editable in Illustrator (plus, I also get the horizontal 'chunks').
A minimal, complete and verifiable example requires matlab, the violin function linked above and illustrator. But if it helps, here's the matlab code to produce a similar figure. I save by clicking on Figure -> save as. (But as I said above I tried the print2eps function and that was the same).
X = rand(100,6);
figure; violin(X)
I tried the following, didn't work either.
set(gcf, 'Renderer', 'painters')
As the author of the question suggests, I also wasn't able to export an editable (vectorized) .eps file into Illustrator. However, exporting it as .pdf does the trick. The 'fill' for the violin plots is weird, though, and has horizontal sections (perhaps something to do with the way the density estimate is being plotted?) all over. I was able to fix this and make the plots normal (with solid filled shades): select all the horizontal sections/chunks using the magic wand tool, and then increase opacity to 100% (it is set to 50 based on the exported file). Once all the required edits are made, export the file as .tiff and it seems to look fine. Hope this replicates, and thus helps! (my MATLAB version is 2016, and Illustrator version is the CS5)

MATLAB: Center displayed text?

How can I center the text printed by display('the text')?
Eg, like the text you get when entering matlab.
A function to get the width of the current terminal will do to (I'll figure it out from there).
with a fairly new version of matlab you can do:
sz=get(0, 'CommandWindowSize');
command_line_width = sz(1);
Otherwise, you'll have to use a mex file:
see this link http://www.mathworks.com/matlabcentral/newsreader/view_thread/25315