Exporting Bokeh Plots - python-3.x

Matplotlib when you invoke the show function, it will open a small python window and show the chart. How can I make Bokeh do the same? I don't want to save a file or open a browser windows. I want to to output like matplotlib. Why? Because I want to show its graphs inside Microsoft Power BI. So it has to produce some sort of image I guess.

Bokeh's normal operation is to generate web content, i.e. HTML+JS that can drive interactive visualizations in the browser. Doing that is explicitly the main reason it was created. However, it is possible to export Bokeh plots as PNG files:
from bokeh.io import export_png
export_png(plot, filename="plot.png")
Note that this will save a file to disk, not open any sort of application window. There is nothing built into Bokeh to auto-open except Bokeh HTML output to browsers.

Related

Output of Plotly in PowerPoint

Is it possible to use an interactive graph created with Python package Plotly in PowerPoint? Is it possible to insert a plotly output in a slide?
To my knowledge and experience, if you want to show the interactive image within PPT, my current answer is no. Because previously I tried to do the same thing for Plotly or Bokeh figures. I looked around and in the end, I saw somebody answered on a Microsoft discussion page, the answer was NO.
But one thing that works is that you can input your figure (html file) as a hyperlink within the ppt. Then when you click it, it opens on your browser, you can still interact with it, although it is not in ppt!
If you are making a presentation via online platforms like Zoom, you can just switch the screen that you are sharing.
There used to be a PowerPoint add-in that made it possible to integrate interactive charts published on plotly Chart Studio into the presentation. Unfortunately, this add-in is no longer available.
EDIT:
I found a workaround to get interactiv plotly charts into my PowerPoint Slides
How to:
Create a Plotly chart studio account
Publish your chart on chart studio like described here
Open PowerPoint and install the Add-In "Webviewer"
Insert the public URL of yout chart from Plotly chart studio
Disadvantage: It only works if the plug-in is installed and Internet access is available.

How to run an animated plot inline with Jupyter Lab?

Running my animated plot in a jupyter notebook is OK. Now trying the same code in Jupyter Lab does not work. I've read a lot of similar situations, tried every solution given, but my plot stays static. No animation running.
This is my extension list, installed and enabled ('jupyter lab build'):
$ jupyter labextension list
JupyterLab v0.35.4
Known labextensions:
app dir: /home/teleuff/anaconda3/share/jupyter/lab
#jupyter-widgets/jupyterlab-manager v0.38.1 enabled OK
#jupyterlab/plotly-extension v1.0.0 enabled OK
jupyter-matplotlib v0.3.0 enabled OK
plotlywidget v1.1.0 enabled OK
%matplotlib inline does not raise JavaScript error, but my plot is not animated.
%matplotlib widget and %pylab inline also have the same effect, only difference is the output line:
Populating the interactive namespace from numpy and matplotlib
Any ideas?
Thanks in advance!
Find and click the little shield on the table frame at the bottom of the screen. Is this shield icon displaying a check mark inside the shield? Hover the mouse above the shield, does the shield then display a message:
{ Active Cell Trusted: x of y shields trusted }
It's likely there is no check mark inside the shield. The reason is the Jupyter extension is designed to be locked down.
Review the Jupyter-notebook security page: Jupyter-notebook
Overview from the security page:
Untrusted HTML is always sanitized
Untrusted JavaScript is never executed
Html and JavaScript in Markdown cells are never trusted
Outputs generated by the user are trusted
Any other HTML or JavaScript (in Markdown cells, output generated by owners) is never trusted
The bottom line and central question of trust is: Did the current user do this? I've found Jupyter Lab security settings make bullet-number 3 the overriding rule.

Figure settings in Interactive Navigation window

I assume it should be possible to change the figure setting after plotting (not in the code).
By default, the Interactive Navigation has these buttons as explained in below link: https://matplotlib.org/users/navigation_toolbar.html?highlight=interactive%20navigation
However, it is not possible to change graph settings through any of these buttons (e.g. change axis limitations, or change label name, or change title). These options are available in MATLAB so it definitely should be there in Python3. How can I add these features to Interactive Navigation window?
P.S. My matplotlib version is 3.1.0
"These options are available in MATLAB so it definitely should be there in Python3" There is no indication for that causality being true.
Setting some of the parameters is nonetheless possible when using the Qt backend.
import matplotlib
matplotlib.use("Qt5Agg")
Then a respective button is available

Using Cairo, how can I open up a window and draw lines by using inputs from a console?

I'm trying to make an application where when a user inputs a direction, it moves a point towards that direction (basically creates a path like say right,right,right makes it draw a line ---), but how do I open the image in real time as Cairo always saves the image? I want the person to be able to input it from the console. I am new to Cairo and its functions and I only have experience with consoles only.
I haven't seen a way to open it in a new window, it only saves in a png file.
Cairo does rendering. It does not do things like interacting with a windowing system. For that, you can use Gtk+. Gtk+ does use cairo for its rendering.

set window icon tkinter macosx

This line works fine for my Windows program.
When i run this same file on the Mac OS X, I get a blank page instead of my icon.
Here is the windows line:
self.iconbitmap("Boss.ico")
I have searched relentlusly for an answer I want this icon to work on both platforms. self is the root Tk window if your wondering if it's root or not.
Note: I have tried using icns, .xbm , .gif by loading a photo image and setting thru window attributes all produce the same blank page on the mac.
After 5 days of searching, and this post having been viewed at least 15 times I went directly to the tk/tcl documentation. If I understand this correctly, apparently there is no way to properly set the icon for mac OS X without using special library or other sort of hacks. It would be nice if there were a mac specific documentation for the tkinter library but alas there isn't that I have found. here is the part of the documentation I found:
wm iconphoto window ?-default? image1 ?image2 ...? Sets the titlebar
icon for window based on the named photo images. If -default is
specified, this is applied to all future created toplevels as well.
The data in the images is taken as a snapshot at the time of
invocation. If the images are later changed, this is not reflected to
the titlebar icons. Multiple images are accepted to allow different
images sizes (e.g., 16x16 and 32x32) to be provided. The window
manager may scale provided icons to an appropriate size. On Windows,
the images are packed into a Windows icon structure. This will
override an ico specified to wm iconbitmap, and vice versa.
On X, the images are arranged into the _NET_WM_ICON X property, which
most modern window managers support. A wm iconbitmap may exist
simultaneously. It is recommended to use not more than 2 icons,
placing the larger icon first.
On Macintosh, this currently does nothing.
if anyone has a working solution please post this. I want to accomplish this so that any system can open a freshly installed python and run my application without installing any additional library.
#GarryHurst This is not a solution but I sort of get the idea now:
On Mac, TK decided that the icon will never appear on the window title bar.
Instead, it shows up as the app's Dock icon.
It's most probably a by-design or won't fix issue on their side.
It is showing the icon of the file you are putting in the directory so setting the file to be an app will set the window icon to be the icon of that app.
for example:
root.iconbitmap("/Users/homedir./Desktop/Test apps/Clicker.app")
tk window with icon
I have a coup. Why not change mind, like this.
The emoji library is enough to choose a good-looking icon.
We can do that.:-D
Code
Effect

Resources