-1

I'm newbie in plotting with python so can not really figure out some things, sorry. The matter is that according to documentation I could only plot images with four axis without any modification.

So, I've found couple tutorials, but still could plot only something like this: now

My question is: where to find tutorials to be able plot something like thisgoal

As you can see there is no top and right axis and years text direction is changed.

Community
  • 1
  • 1
im_infamous
  • 972
  • 1
  • 17
  • 29

2 Answers2

1

It's actually (at least) two questions:

  • Rotating the labels can be done with setp; see answer here

  • This axes props demo shows how to get the grid-like effect in your graph.

Community
  • 1
  • 1
Ami Tavory
  • 74,578
  • 11
  • 141
  • 185
0

Done.

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import matplotlib.pyplot as plt
import matplotlib.ticker

import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager

# ------------ Main Data ----------------

xlist = [x for x in xrange(2001, 2016, 1)]
ylist = [0, 1, 3, 3, 5, 7, 4, 4, 5, 10, 10, 30, 27, 43, 45]

# ---------------------------------------

# size of plot in inches
fig = plt.figure(figsize=(9.5, 5))

# init plot
plt.plot(
    xlist,
    ylist,
    linestyle = "-",
    marker = "D",
    color = "#5184be",
    markerfacecolor = "#5184be",
    linewidth = 2)

# axes style
axes = plt.gca()
axes.yaxis.grid(b=True, color='#c0c0c0', linestyle='-', linewidth=2)
axes.set_axisbelow(True)

# Labels
axes.set_xlabel(u'Loads, pts.', fontproperties=prop)
axes.set_ylabel(u'Year, y', fontproperties=prop)

# create line style
locator = matplotlib.ticker.MultipleLocator (base=1)

# set line style
axes.xaxis.set_major_locator (locator)

# view plot
plt.show()
im_infamous
  • 972
  • 1
  • 17
  • 29