1

I have a matplotlib script for drawing several lines showing the results for 8, 16, 32, and 64 bit configurations. The figure is a bit crowded and in order to make it easier to read I would like to add these number as markers. Also I prefer to have a circle around the text. This means that the marker will be a text with a surrounding circle.

My code is like this:

#!/usr/bin/env python
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
import numpy as np

# Turn off DISPLAY
#matplotlib.use('Agg')
import pylab

fig = plt.figure()
ax = fig.add_subplot(1,1,1)

# T = 16
plt.plot((1,2,3,4),(18.25,15.5,14.15,14.07), linestyle='--', lw=2, marker="D", markersize=7, color='r', label="Stepped Parity 16-bit");
# T = 32
plt.plot((1,2,3,4),(11.90,10.29,9.23,9.11), linestyle='--', lw=2, marker="*", markersize=10, color='r', label="Stepped Parity 32-bit");
# T = 64
plt.plot((1,2,3,4),(6.64,6.20,5.53,5.39), linestyle='--', lw=2, marker="H", markersize=8, color='r', label="Stepped Parity 64-bit");

# T = 16
plt.plot((1,2,3,4),(25.52,22.51,21.05,21.02), linestyle='-', lw=2, marker="D", markersize=7, color='b', label="Interleaving 16-bit");
# T = 32
plt.plot((1,2,3,4),(17.18, 15.13, 13.56, 13.51), linestyle='-', lw=2, marker="*", markersize=10, color='b', label="Interleaving 32-bit");
# T = 64
plt.plot((1,2,3,4),(8.84, 8.31, 7.97, 7.91), linestyle='-', lw=2, marker="h", markersize=8, color='b', label="Interleaving 64-bit");

plt.xlim([0.75, 4.25])
plt.ylim([0, 30])

plt.xticks([1,2,3,4],[512, 1024, 2048, 4096], fontsize=14)
plt.yticks(fontsize=14)

plt.xlabel('# of Words', fontsize=16)
plt.ylabel('Area Overhead', fontsize=16)

# Percentage sign in Y-axis
fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
yticks = mtick.FormatStrFormatter(fmt)
ax.yaxis.set_major_formatter(yticks)  

plt.legend(ncol=2)

# Save in PDF file
pylab.savefig("Output.pdf", dpi=400, bbox_inches='tight', pad_inches=0.05)

1 Answer 1

2

You can have all the kinky latex as your markers you want, including text. It will probably end up looking really bad though... But at least now you have a wider arrangement of symbols to choose from.

plt.plot((1,2,3,4),(11.90,10.29,9.23,9.11), linestyle='--',
         lw=2, marker="$32$", markersize=17, color='r',
         label="Stepped Parity 32-bit")

Just make sure they're sent inside the "$ $" tags as described in the manual.

Python 3 matplotlib 1.3.1 Win7 tested. Also please wrap your lines at 65 char length. It's just so much more comfortable to read.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.