Scientific mode tutorial
In this tutorial, you operate in Scientific Mode and use Matplotlib and NumPy packages to run and debug a Python code with data visualization.
Before you start, make sure that Conda is installed.
Creating a Scientific project
Create a PyCharm project with the scientific settings predefined
Open the New Project wizard ( File | New | Project ).
Choose Scientific project type.
In the project settings dialog window, specify a project name, ensure that Conda is selected as the new environment, and alter the default data folder (if needed), then click Create .
Open the main.py file and add the following code sample:
Process warnings shown for the numpy and matplotlib imports and enable the packages in the project.
Running
Run your scientific project Shift+F10 . The code is executed and shows two graphs in the SciView. Clicking the preview thumbnail displays the respective graph:
You can modify the project code to plot only one graph at a time. In the scientific mode, you can execute fragments of your code by creating code cells.
To execute code cells:
Modify the main.py file by adding the "#%%" lines.
In the gutter, click the icon Ctrl+Enter on line with the scatter plot cell mark. Only the scatter graph will be built.
Now click the icon or press Ctrl+Enter on the line with the y versus x plot cell mark. The corresponding graph should appear.
Debugging
Let’s put a breakpoint at the line:
This line appears twice in our example code, and so there will be two breakpoints.
Right-click the editor background and from the context menu choose Debug ‘main’ .
You see the Debug tool window and the grey characters in the editor. This is the result of the inline debugging, which is enabled.
The line with the first breakpoint is blue highlighted. It means that the debugger has stopped at the line with the breakpoint, but has not yet executed it. If we execute this line (for example, by clicking the button on the stepping toolbar of the Debug tool window), we’ll see the graph:

Next, look at the Variables tab of the Debug tool window. If you click the View as Array link nearby the area array, the Data tab in the SciView window opens:

When you process excessive amount of data, you might experience degradation of debugging performance if the debugger loads variable’s values synchronously or asynchronously . It is recommended to switch to the On demand mode by selecting the corresponding loading policy. See Managing Variables Loading Policy for more information.
Mind the only row of figures in the Data tab in the SciView — it’s explained by the fact that the area array is one-dimensional.
Running in console
Right-click the editor background and choose the Run File in Console command:

This command corresponds to running a run/debug configuration for the main.py file with the Run with Python console checkbox selected:

When this command is run, the >>> prompt appears after the output in the Run tool window, and you can execute your own commands.
Summary
So, what has been done with the help of PyCharm?
The file main.py was created and opened for editing.
The source code has been entered (note the powerful PyCharm’s code completion!)
Русские Блоги
Нажмите на Graphviz-2.38.msi для загрузки и установки.
Файл gvedit.exe в каталоге bin нажмите правой кнопкой мыши, чтобы сгенерировать ярлык на рабочем столе.
2, настроить переменные среды
В пути системной переменной добавьте путь к установке каталога Graphviz.
3, проверить установку
Win + R Введите CMD, откройте интерфейс командной строки Windows, введитеdot -versionОтказ Отображает соответствующую информацию о версии Graphviz, то есть конфигурация установки успешна.
4, установите графики в Pycharm
Файл-> Настройка-> Проект-> Интерпретатор проекта, «+» в красном круге в соответствии с изображением, запросgraphvizНажмите «Установить».
How to See Plotly Graphs in PyCharm
In this article, let us discuss how we can display plots in a PyCharm IDE.
In this article, we will be using PyCharm Professional as it allows full support for Jupyter Notebooks and Interactive Python Sessions.
Method 1 – Using Interactive Jupyter Notebooks
The best way to create and view Plotly Figures in PyCharm is using Jupyter Notebooks instead of regular Python Files.
To create a Jupyter Notebook in Pycharm, Select File -> New and Select New File.

Add the filename ending with .ipynb extension. Click on Return to save the file.

You can now edit the file and add your source code in the cells that appear.
Keep in Mind that the default Plotly Rendering engine does not support plain Python files. Hence, running the fig.show() function inside a file running in .py file will not work.
Method 2 – Use fig.Show() Function
When working with Plotly, there are two main ways of displaying a specific figure. The first is calling the figure and allowing the environment to display the figure. For example:
import plotly. express as px
df = px. data . stocks ( )
fig = px. line ( df , x = "date" , y = "AMZN" )
In this case, we are calling the fig object and allow the current environment to display the figure.
However, this will heavily depend on the set renderer. Sometimes PyCharm may not be configured with a default renderer which will prevent it from displaying the image.
To resolve this, use the fig.show() function and pass the renderer value as:
This will force PyCharm to use the Jupyter Notebook server to display the images. You can also set the renderer as png if you want to view the plot as a static image.
Method 3 – Install the Required Packages
Before running the fig.show() function, it is good to ensure you have the necessary packages.
You can do it by running the command:
Method 4 – Set Correct Project Interpreter
Before running your Jupyter code, it is good to ensure that the project is using the correct interpreter.
To configure the project interpreter in PyCharm, press CTRL+ ALT + S to open the Editor settings.
Select Python Interpreters and select the target interpreter for your selected project.

Click on Apply to save the changes. This may require you to reload your project.
Conclusion
In this article, we covered the various method and techniques you can employ to run and view Plotly figures in PyCharm.
About the author

John Otieno
My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list
Как рисовать графики в pycharm
Нажмите на Graphviz-2.38.msi для загрузки и установки.
В пути системной переменной добавьте путь к установке каталога Graphviz.
Win + R Введите CMD, откройте интерфейс командной строки Windows, введитеdot -versionОтказ Отображает соответствующую информацию о версии Graphviz, то есть конфигурация установки успешна.
4, установите графики в Pycharm
Файл-> Настройка-> Проект-> Интерпретатор проекта, «+» в красном круге в соответствии с изображением, запросgraphvizНажмите «Установить».
Как увидеть графики в Pycharm?
- щелкните правой кнопкой мыши и выберите « Запустить файл в консоли Python ».
- после этого откроется браузер с выводом графика

- $ conda create -n pycharm-plotly python
- $ conda activate pycharm-plotly
- $ conda install -c plotly plotly==4.0.0
- $ conda install «notebook>=5.3» «ipywidgets>=7.5»
- $ conda install -c plotly plotly-orca psutil requests
Scientific mode tutorial
In this tutorial, you operate in Scientific Mode and use Matplotlib and NumPy packages to run and debug a Python code with data visualization.
Before you start, ensure the following is installed:
Creating a Scientific project
Create a PyCharm project with the scientific settings predefined
Open the New Project wizard ( File | New | Project ).
Choose Scientific project type.
In the project settings dialog window, specify a project name, ensure the Conda is selected as the new environment, and alter the default data folder (if needed), then click Create .
Open the main.py file and add the following code sample:
Process warnings shown for the numpy and matplotlib imports and enable the packages in the project.
Running
Run your scientific project Shift+F10 . The code is executed and shows two graphs in the SciView. Clicking the preview thumbnail displays the respective graph:

You can modify the project code to plot only one graph at a time. In the scientific mode, you can execute fragments of your code by creating code cells.
To execute code cells:
Modify the main.py file by adding the «#%%» lines.
In the gutter, click the icon Ctrl+Enter on line with the scatter plot cell mark. Only the scatter graph will be built.
Now click the icon or press Ctrl+Enter on the line with the y versus x plot cell mark. The corresponding graph should appear.
Debugging
Let’s put a breakpoint at the line:
This line appears twice in our example code, and so there will be two breakpoints.
Right-click the editor background and from the context menu choose Debug ‘main’ .
You see the Debug tool window and the grey characters in the editor. This is the result of the inline debugging, which is enabled.
The line with the first breakpoint is blue highlighted. It means that the debugger has stopped at the line with the breakpoint, but has not yet executed it. If we execute this line (for example, by clicking the button on the stepping toolbar of the Debug tool window), we’ll see the graph:

Next, look at the Variables tab of the Debug tool window. If you click the View as Array link nearby the area array, the Data tab in the SciView window opens:

When you process excessive amount of data, you might experience degradation of debugging performance if the debugger loads variable’s values synchronously or asynchronously . It is recommended to switch to the On demand mode by selecting the corresponding loading policy. See Managing Variables Loading Policy for more information.
Mind the only row of figures in the Data tab in the SciView — it’s explained by the fact that the area array is one-dimensional.
Running in console
Right-click the editor background and choose the Run File in Console command:

This command corresponds to running a run/debug configuration for the main.py file with the Run with Python console checkbox selected:

When this command is run, the >>> prompt appears after the output in the Run tool window, and you can execute your own commands.
Summary
So, what has been done with the help of PyCharm?
The file main.py was created and opened for editing.
The source code has been entered (note the powerful PyCharm’s code completion!)