• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spesmilo / electrum / 5530949322014720

10 Jun 2025 06:41PM UTC coverage: 59.806% (-0.003%) from 59.809%
5530949322014720

push

CirrusCI

web-flow
Merge pull request #9934 from f321x/matplotlib_warning

qt: provide more detailed warning for plot feature, change matplotlib backend

0 of 1 new or added line in 1 file covered. (0.0%)

2 existing lines in 2 files now uncovered.

21929 of 36667 relevant lines covered (59.81%)

2.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/electrum/plot.py
1
# note: This module takes 1-2 seconds to import. It should be imported *on-demand*.
2

3
import datetime
×
4
from decimal import Decimal
×
5
from collections import defaultdict
×
6

7
import matplotlib
×
NEW
8
matplotlib.use('QtAgg')
×
9
import matplotlib.pyplot as plt
×
10
import matplotlib.dates as md
×
11

12
from .i18n import _
×
13
from .bitcoin import COIN
×
14

15

16
class NothingToPlotException(Exception):
×
17
    def __str__(self):
×
18
        return _("Nothing to plot.")
×
19

20

21
def plot_history(history):
×
22
    if len(history) == 0:
×
23
        raise NothingToPlotException()
×
24
    hist_in = defaultdict(Decimal)
×
25
    hist_out = defaultdict(Decimal)
×
26
    for item in history:
×
27
        is_lightning = item.get("lightning", False)
×
28
        if not is_lightning and not item['confirmations']:
×
29
            continue
×
30
        if item['timestamp'] is None:
×
31
            continue
×
32
        value = Decimal(item['value'].value)/COIN
×
33
        date = item['date']
×
34
        datenum = int(md.date2num(datetime.date(date.year, date.month, 1)))
×
35
        if value > 0:
×
36
            hist_in[datenum] += value
×
37
        else:
38
            hist_out[datenum] -= value
×
39

40
    f, axarr = plt.subplots(2, sharex=True)
×
41
    plt.subplots_adjust(bottom=0.2)
×
42
    plt.xticks(rotation=25)
×
43
    ax = plt.gca()
×
44
    plt.ylabel('BTC')
×
45
    plt.xlabel('Month')
×
46
    xfmt = md.DateFormatter('%Y-%m-%d')
×
47
    ax.xaxis.set_major_formatter(xfmt)
×
48
    axarr[0].set_title('Monthly Volume')
×
49
    xfmt = md.DateFormatter('%Y-%m')
×
50
    ax.xaxis.set_major_formatter(xfmt)
×
51
    width = 20
×
52

53
    r1 = None
×
54
    r2 = None
×
55
    dates_values = list(zip(*sorted(hist_in.items())))
×
56
    if dates_values and len(dates_values) == 2:
×
57
        dates, values = dates_values
×
58
        r1 = axarr[0].bar(dates, values, width, label='incoming')
×
59
        axarr[0].legend(loc='upper left')
×
60
    dates_values = list(zip(*sorted(hist_out.items())))
×
61
    if dates_values and len(dates_values) == 2:
×
62
        dates, values = dates_values
×
63
        r2 = axarr[1].bar(dates, values, width, color='r', label='outgoing')
×
64
        axarr[1].legend(loc='upper left')
×
65
    if r1 is None and r2 is None:
×
66
        raise NothingToPlotException()
×
67
    return plt
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc