How to plot a high resolution graph
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Creating high-resolution plots is an essential task for data visualization, especially when you need to present data clearly and professionally. This article will guide you through the steps and considerations necessary to create high-resolution graphs using popular tools like Matplotlib in Python.
Introduction to High-Resolution Graphs
High-resolution graphs or plots are those that provide a clear and detailed view of data which is crucial for presentations or publications where clarity is key. High resolution is typically characterized by a higher DPI (dots per inch), ensuring that the plot looks sharp and well-detailed even when enlarged.
Why High Resolution?
- Clarity in Presentation: A high-resolution graph makes it easy to differentiate between lines, points, and other graphical elements.
- Publication Quality: Journals and magazines often have strict requirements for image quality.
- Professional Appearance: High-resolution images enhance the professionalism of reports or presentations.
Technical Considerations
- DPI (Dots Per Inch):
- DPI is a measure of graphical resolution. The higher the DPI, the better the clarity of the image.
- Common DPI settings are 72 (screen resolution), 300 (print quality), or higher for specific needs.
- Vector vs. Raster Graphics:
- Vector graphics (e.g., SVG, PDF) are resolution-independent and scale without losing quality.
- Raster graphics (e.g., PNG, JPEG) may lose quality when scaled. Use a high DPI for these to ensure clarity.
- File Formats:
- PNG: Supports lossless compression, good for transparency.
- JPEG: Suitable for photographic images but lossy.
- SVG/PDF: Vector formats, ideal for high-quality and scalable graphics.
Example Using Matplotlib
Matplotlib is a widely used library in Python for creating static, interactive, and animated plots.
Basic Example
To create a plot and save it with a high resolution in Matplotlib, follow these steps:
- Figure Size: `figsize=(10, 6)` specifies the size of the figure in inches. Larger images generally have better clarity.
- DPI Setting: The `dpi=300` argument in `plt.savefig()` ensures the image is saved at a high resolution.
- File Format: By saving the plot as a PNG (`sine_wave.png`), you ensure lossless compression and transparency support.
Related reading
- How to plot a learning curve for a keras experiment?
- How to Plot and save a tensor as an image in Tensorflow
- How to plot gradient descent using plotly
- How to plot in multiple subplots
- How to post a task on a celery-rabbitmq queue in PHP?
- How to preserve insertion order in HashMap?
- How to plot multiple dataframes in subplots
- How to plot multiple functions on the same figure

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.