PyCharm Scientific Mode

24966 VIEWS

Over the years, Python has increased in popularity as a tool for math-intensive data science, machine learning and other forms of analytics. This trend can be attributed to Python’s simplicity and the availability of libraries such as NumPy and scikit-learn, which are designed for mathematical analysis. There are also plotting libraries like Matplotlib that mimic the interface of MATLAB’s plotting functions, making it fairly easy to make the switch.

With powerful libraries available, a powerful IDE is needed that can support functions like graphing and analyzing variables in the program’s scope. These features are provided by PyCharm, a popular Python IDE. This post will look at the features PyCharm provides and how to use them.

What is PyCharm Scientific Mode?

PyCharm scientific mode bears some similarities to MATLAB, so making the switch should be comfortable for users who have previous experience. Let’s jump into how to get started with PyCharm’s scientific mode.

The first step is to download PyCharm from the official website and install it. Next, run it and click on “Create New Project” to start creating a project; click on “scientific mode,” configure your project interpreter, and click “Create” to create your project. You should now have a window like the image below. (Don’t worry if you don’t have the same color theme.)

Fig 1. PyCharm Window in Scientific Mode

On the far right, you’ll find a panel that includes ScieView, R Packages, R Graphics and Database. SciView allows you to view your plots and data points right in the IDE window. This eliminates the need to switch between windows to view plots, which streamlines the workflow of analyzing plots. R Packages and R Graphics are useful if you have an R interpreter configured; however, we will only focus on using Python for this post.

There is also a window at the bottom right of the screen that allows you to view the variables in the last program you’ve run, which is useful for analyzing them. If no program has been run, the window will show Special Variables (which are Python’s built-in variables). You can click on the drop-down arrow to see what it contains.

Example

Now, let’s run a simple program and see PyCharm’s scientific mode in action. Copy and paste the code below into PyCharm and click the Run button.

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from numpy import sin, cos
 
 
fig = plt.figure()
 
# preferred method for creating 3d axis
ax = fig.add_subplot(111, projection='3d')
r = 10
c = 50
t = np.linspace(0, 5000, 100)
 
# parametric equation of a helix
x = r*cos(t)
y = r*sin(t)
z = c*t
 
ax.scatter(x, y, z, zdir='z', lw=2, c='g', marker='^')
plt.show()

Source: https://sweetcode.io/visualizing-data-python-matplotlib/

After running the code, you should see the plot in the SciView window, and the variables in the program’s scope should now be visible in the bottom-right window. This feature can be useful for debugging and for trying out new things in the interactive console.

Fig 2. Plot in PyCharm Window

Summary

PyCharm scientific mode is a special PyCharm IDE mode that provides tools to simplify your scientific or analytics workflow. This mode allows you to view plots in the IDE window, view variables in the last-run program, and provides features for use in the R programming language.


Stephan is a third-year student at Ashesi pursuing an undergraduate degree in computer engineering. Stephan is passionate about technology and is focused on continuous learning to gain new skills. He has worked in software development, and has worked on IoT projects and designing products for the health sector.


Discussion

Click on a tab to select how you'd like to leave your comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Menu
Skip to toolbar