Home > database >  Turn off corner rounding in matplotlib plot with thicker lines
Turn off corner rounding in matplotlib plot with thicker lines

Time:06-15

Question:

Is it possible to turn off "corner rounding" when using plot in matplotlib?

Setup:

  • I am trying to present a complicated nonsmooth function in a presentation.
  • As a default (understandably) matplotlib rounds corners. (This is especially visible when the linewidth is increased.)
  • I need more linewidth so the plot can be seen when the figure is projected.

Example:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-1, 1, 1001)
y = abs(x)
plt.plot(x, y, linewidth=10)

plt.show()

produces the image:

absolute_value

Attempts:

  • Increasing the number of points in x does not resolve this issue.
  • Note that the point x=0 is included in the plot.

Summary:

The plotted curve above appears rounded at x=0 when the function is not.

CodePudding user response:

You can specify a enter image description here

  • Related