\n","author":{"@type":"Person","name":"Fortunato"},"upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"
You need to specify solid_capstyle='butt'
in the plot()
function.
ax[1].plot([3.0, 3.0], [55924, 56926], linewidth=30., solid_capstyle='butt')\nax[1].plot([3.0, 3.0], [57167, 58225], linewidth=30., solid_capstyle='butt')\n
\nFor line's join style
and cap style
, consult this document.
Reputation: 567
I am trying to display a series of events that take place sequentially. The default linewidth
makes the plots difficult to see. However, if I increase the linewidth, the length of the lines also changes. Is there anyway to increase the width of the lines only?
e.g.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1,2, figsize=(15,6))
ax[0].set_title('linewidth = 1.0', fontsize=12)
ax[0].plot([3.0, 3.0], [55924, 56926], linewidth=1.)
ax[0].plot([3.0, 3.0], [57167, 58225], linewidth=1.)
ax[0].plot([2.5, 3.5], [56926,56926], linewidth=1., color='black')
ax[0].plot([2.5, 3.5], [57167,57167], linewidth=1., color='black')
ax[1].set_title('linewidth = 30.0', fontsize=12)
ax[1].plot([3.0, 3.0], [55924, 56926], linewidth=30.)
ax[1].plot([3.0, 3.0], [57167, 58225], linewidth=30.)
ax[1].plot([2.5, 3.5], [56926,56926], linewidth=1., color='black')
ax[1].plot([2.5, 3.5], [57167,57167], linewidth=1., color='black')
Upvotes: 1
Views: 5008
Reputation: 18812
You need to specify solid_capstyle='butt'
in the plot()
function.
ax[1].plot([3.0, 3.0], [55924, 56926], linewidth=30., solid_capstyle='butt')
ax[1].plot([3.0, 3.0], [57167, 58225], linewidth=30., solid_capstyle='butt')
For line's join style
and cap style
, consult this document.
Upvotes: 3
Reputation: 2519
Try Axes.vlines instead
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(5, 5))
ax.set_title('linewidth = 30.0', fontsize=12)
# vlines
ax.vlines(x=3, ymin=55924, ymax=56926, linewidth=30)
ax.vlines(x=3, ymin=57167, ymax=58225, linewidth=30)
# hlines
ax.hlines(y=56926, xmin=2.5, xmax=3.5, linewidth=1., color='black')
ax.hlines(y=57167, xmin=2.5, xmax=3.5, linewidth=1., color='black')
Upvotes: 2