How to view altair chart on non-notebook environment - altair

I have created a program by using altair library in .py file not in notebook.
In this program the plot is plotted by using iris dataset between sepalWidth and petalWidth with the regression line code is right but as I have created this in python file so after running the code in the terminal it throws the NotImplementedError.
My question is how to view the altair chart if I'm writing the program in python file.
I read out the documentation but didn't understand which renderer I have to enbale.
This is the error which I am facing

See Working in non-notebook environments in Altair's documentation for information on displaying charts in non-notebook environments. If you have specific issues with any of those approaches, please edit your question with a minimal reproducible example of the issue you're seeing.

Related

can you export data from vscode to xlsx/csv while working in jupyter notebook file?

What I mean in my question is, in pycharm (I use professional though since I have the access from my university), when I am working with a dataset in jupyter notebook, after some operations (like data filtering) I can export it right away to xlsx or csv in the filtered form (see screenshot).
Can you do something like this in VS Code?

Use ams math style in Jupiter notebook

I am learning how to do equation numbering using ams math in local Jupyter notebook. As per the documentation, it says to make changes in _config.yml file. But I am not sure where to find it on my Mac. If it helps, I have the file jupyter_notebook_config.py in ~/.jupyter directory. But they don't look the same.
Can I kindly get some help here (example'll be appreciated), how to work with _config.yml file. thanks in advance.
The documentation you linked to is for a project called jupyter-book. If you're using that, then, as #MattDMo said, follow the example from the tutorial and add the _config.yml in the folder that contains your book.
If you're using a regular Jupyter Notebook, you can disregard that and just write the LaTeX in a Markdown cell, where it will be rendered (by MathJax rather than MyST), without any extra config.

plotnine: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail

I am trying to use plotnine to generate some graphs. I import the required libraries:
from plotnine import *
from plotnine.data import mpg
And then, if I run the following code in PyCharm I get a Warning message, the window plot
shows a "No answer" message and I am forced to restart the python terminal:
(ggplot(mpg) # defining what data to use
+ aes(x='class') # defining what variable to use
+ geom_bar(size=20) # defining the type of plot to use
)
<ggplot: (150517199824)>
C:\Users\alvaromc317\miniconda3\envs\general\lib\site-packages\plotnine\ggplot.py:363: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
However, If I start a python terminal from windows cmd terminal and run the same script as before, I get no error message and I see the plot with no problem.
What is happening and how do I get to use plotnine in pycharm?
In case it is needed, I work using a Windows 10 machine and python 3x based on miniconda.
I'm having a similar problem, but on MacOS using the commercial addition of PyCharm.
From this github issue and this JetBrains issue, it looks like it might be related to a PyCharm bug.

Pyside to build PyQT designer 4 UI file always results in error

Using Pyside-uic -o pythonfilename.py uifilename.ui to convert my PyQT4 designer GUI to python code. Seems to build just fine with no errors, but when I run the file, it consistently crashes, with type errors I can't solve.
First error gave me trouble because I set a "max size". When I removed the max size, the error changed to be a problem with the palette. I removed the palette settings, and replaced it with style sheets, and now it's giving me the error:
"TypeError: QWidget.setFont(QFont): argument 1 has unexpected type 'PySide.QtGui.QFont'"
I doubt there are this many problems with using Pyside to build PyQT UI files(because it seems to be a pretty standard way of doing it), so that leaves me to believe it's something i'm doing.
**Just a note with a bit more info.
This is software we've been using for some time, and the existing UI was built using this exact method. I inherited the file, and was asked to update the UI, and left with instructions on how to do it. I updated the existing ui file, saved it out, and ran the "Using Pyside-uic -o pythonfilename.py uifilename.ui" command. No errors from the build, but %100 of the time i've tried using this method, it has failed.
I tried googling the answer for hours, and proposed the question to other people.
I solved the issue. After pyside spits out the new python file (built from the UI file), theres a line of code at the beginning that will say something along the lines of "from PySide import QtCore, QtGui"
"PySide" has to be changed to "PyQt4".

MacOS app built with py2app won't render dot graph into pdf file

I have built a standalone macOS app using py2app from a single .py script. The app is supposed to generate and render some graph using graphviz framework.
Running the MyApp.app by double-clicking works fine until it has to render and preview the resulting graph (in pdf), then nothing happens. I found that the .gv source file is created, but the rendered .pdf is never created nor shown.
Interestingly, running the .py script manually through terminal worked fine, same thing with running it through PyCharm and even running /MyApp.app/Contents/MacOS/MyApp from terminal.
Relevant code:
G = Digraph(path)
# add some nodes and edges here
G.render(view=True)
So far I have tried changing output formats for rendering and changing the path for generated .gv file, but with no success. Any advice would be greatly appreciated.
P.S. I'm using Python v3.7.0, graphviz v2.40.1 and py2app v0.15

Resources