File: test_lines.py

package info (click to toggle)
python-mpld3 0.3git%2B20140910dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,808 kB
  • ctags: 1,095
  • sloc: python: 3,595; makefile: 187
file content (35 lines) | stat: -rw-r--r-- 993 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Plot to test line styles"""
import matplotlib.pyplot as plt
import mpld3


def create_plot():
    fig, ax = plt.subplots()

    x = [0, 1]

    for i, color in enumerate(['red', 'green', '#0000FF']):
        x = 1 + 6 * i
        for j, alpha in enumerate([0.3, 0.6, 1.0]):
            for k, linestyle in enumerate(['solid', 'dashed',
                                           'dashdot', 'dotted', '--']):
                y = 0.5 + k + 0.33 * j
                lines = ax.plot([x, x + 2.5, x + 5], [y, y + 0.2, y],
                                lw=6 * alpha,
                                c=color, ls=linestyle, alpha=alpha)
                if linestyle == '--':
                    lines[0].set_dashes([8, 4, 2, 4, 2, 4])

    ax.set_ylim(0, 5.5)
    ax.set_title("Line Styles, Widths, Transparencies", size=20)
    return fig


def test_lines():
    fig = create_plot()
    html = mpld3.fig_to_html(fig)
    plt.close(fig)


if __name__ == "__main__":
    mpld3.show(create_plot())