Python Matplotlib Add a Colorbar to Each Subplot

Python Matplotlib Add Colorbar to Each Subplot

As a developer, I was working on a Python project where I had to visualize multiple datasets side by side using subplots. Each subplot had its own scale and color mapping. The challenge I faced was how to add a separate colorbar to each subplot in Matplotlib. At first, I tried to use a single … Read more >>

Customize Matplotlib Scatter Plot Legend Facecolor in Python

Customize Matplotlib Scatter Plot Legend Facecolor

As a Python developer with over seven years of experience working extensively with Matplotlib, I’ve learned that small details can make a huge difference in your data visualizations. One such detail is customizing the legend’s face color in scatter plots. This simple tweak can improve the readability and aesthetics of your plots, especially when presenting … Read more >>

Use tight_layout Colorbar and GridSpec in Matplotlib

tight_layout Colorbar in Matplotlib

I’ve come to appreciate the importance of creating clean, professional plots that communicate data effectively. Whether you’re visualizing economic trends across U.S. states or analyzing sales data, your plots need to be clear and well-organized. Two powerful tools in Matplotlib that help achieve this are tight_layout and GridSpec, especially when combined with colorbars. In this … Read more >>

51 Machine Learning Interview Questions and Answers

Machine Learning Interview Questions and Answers

Machine learning interviews test a candidate’s knowledge and problem-solving skills in this fast-growing field. Employers ask technical questions to assess understanding of key concepts, algorithms, and practical applications. Preparing for common interview questions can help job seekers showcase their expertise and land exciting roles in machine learning. Knowing what to expect allows candidates to practice … Read more >>

Matplotlib Scatter Marker: Shape, Size and Color

Matplotlib scatter marker: a reference chart showing every marker style and its code

Three arguments control how a Matplotlib scatter marker looks, and each one does a single job: s is the one that surprises people. It is an area, so s=400 is twice as wide as s=100, not four times. Every chart below is a real Matplotlib window from Python 3.12.5, Matplotlib 3.11.2, NumPy 2.5.3. Every Matplotlib … Read more >>

PyQt6 QTableWidget: Build, Style and Read a Table

PyQt6 QTableWidget: a real Qt window showing a three column staff table with name, role and city

QTableWidget is the ready-made table in PyQt6. You give it a size, set the header labels, and drop a QTableWidgetItem into each cell: It keeps the data for you, which is what separates it from QTableView. For anything up to a few thousand rows that’s exactly what you want. Screenshots below are real windows on … Read more >>

PyTorch nn.Conv1d: Shapes, Weights and Examples

PyTorch nn.Conv1d: the Command Prompt showing the input shape, output shape, weight shape and parameter count of a 1D convolution

nn.Conv1d is the 1D convolution layer in PyTorch, for signals, time series and text. It expects a 3D tensor of (batch, channels, length): Nearly every problem with it is a shape problem, and the two shapes to keep straight are that input and the weight, which is (out_channels, in_channels, kernel_size). Runs below are on PyTorch … Read more >>

Python isdigit(): What It Accepts and What It Rejects

Python isdigit: the Command Prompt showing that negative numbers and decimals both return False

isdigit() is a Python string method that returns True when every character in the string is a digit, and False otherwise. Those last two are why you’re probably here. A minus sign isn’t a digit and neither is a full stop, so isdigit rejects most real-world numbers. Everything on this page ran on Python 3.12.5, … Read more >>

Matplotlib Subplot Titles and the Figure suptitle

Matplotlib subplot titles: a two by two grid of bar charts each with its own title under one bold figure title

A Matplotlib subplot title comes from ax.set_title(), and the title over the whole figure comes from fig.suptitle(). They’re different objects on different owners: Use both together and they collide, which is the reason most people end up searching for this twice. The fix is one line and it’s further down. Figures below come from Matplotlib … Read more >>

Draw a Circle in Python Turtle: Arcs, Fills and Polygons

Python turtle circle: the turtle graphics window showing a blue circle drawn with a radius of 100

To draw a circle in Python turtle, call circle() with a radius: The surprise is where it lands. It’s drawn above the turtle rather than around it, and the next section shows why. Every screenshot here is a real turtle window on Python 3.12.5. Drawing a circle in Python turtle One call does it. The … Read more >>