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

ac-i2i-engineering / MatPlus / 13358383023

16 Feb 2025 07:49PM UTC coverage: 87.671% (+87.7%) from 0.0%
13358383023

push

github

web-flow
Merge pull request #6 from ac-i2i-engineering/Branch-Surya

Built Scatterplot and BarPlot objects

129 of 131 new or added lines in 4 files covered. (98.47%)

192 of 219 relevant lines covered (87.67%)

7.07 hits per line

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

94.29
/MatPlus/ScatterPlot.py
1
import matplotlib.pyplot as plt
6✔
2
import numpy as np
6✔
3

4

5
class ScatterPlot:
6✔
6
    def __init__(
6✔
7
        self,
8
        x,
9
        y,
10
        lowerlimx=None,
11
        lowerlimy=None,
12
        upperlimx=None,
13
        upperlimy=None,
14
        sizes=[],
15
        colors=[],
16
        vmin=0,
17
        vmax=0,
18
        width=1,
19
    ):
20
        """Initializes Scatterplot object with the following parameters:
21
        type: type of the plot
22
        x: x-axis data
23
        y: y-axis data
24
        lowerlimx: lower limit of x-axis
25
        lowerlimy: lower limit of y-axis
26
        upperlimx: upper limit of x-axis
27
        upperlimy: upper limit of y-axis
28
        sizes: size of the data points
29
        colors: color of the data points
30
        vmin: minimum value of the color map
31
        vmax: maximum value of the color map
32
        """
33

34
        self.type = type
6✔
35
        self.x = x
6✔
36
        self.y = y
6✔
37
        self.lowerlimx = lowerlimx
6✔
38
        self.lowerlimy = lowerlimy
6✔
39
        self.upperlimx = upperlimx
6✔
40
        self.upperlimy = upperlimy
6✔
41
        self.sizes = sizes
6✔
42
        self.colors = colors
6✔
43
        self.vmin = vmin
6✔
44
        self.vmax = vmax
6✔
45
        self.width = width
6✔
46
        if self.lowerlimx is None:
6✔
47
            self.lowerlimx = np.min(x) * 0.9
6✔
48
        if self.lowerlimy is None:
6✔
49
            self.lowerlimy = np.min(y) * 0.9
6✔
50
        if self.upperlimx is None:
6✔
51
            self.upperlimx = np.max(x) * 1.1
6✔
52
        if self.upperlimy is None:
6✔
53
            self.upperlimy = np.max(y) * 1.1
6✔
54

55
    def plot(self):
6✔
56
        """Plots the scatter plot with the given parameters"""
57
        fig, ax = plt.subplots()
6✔
58
        if len(self.sizes) != 0 and len(self.colors) != 0:
6✔
NEW
59
            ax.scatter(
×
60
                self.x,
61
                self.y,
62
                s=self.sizes,
63
                c=self.colors,
64
                vmin=self.vmin,
65
                vmax=self.vmax,
66
            )
67
        elif len(self.sizes) != 0:
6✔
NEW
68
            ax.scatter(self.x, self.y, s=self.sizes, vmin=self.vmin, vmax=self.vmax)
×
69
        else:
70
            ax.scatter(self.x, self.y, s=20, vmin=self.vmin, vmax=self.vmax)
6✔
71
        plt.xlabel("X-axis")
6✔
72
        plt.ylabel("Y-axis")
6✔
73
        ax.set(
6✔
74
            xlim=(self.lowerlimx, self.upperlimx),
75
            xticks=np.arange(self.lowerlimx + 1, self.upperlimx),
76
            ylim=(self.lowerlimy, self.upperlimy),
77
            yticks=np.arange(self.lowerlimy + 1, self.upperlimy),
78
        )
79
        plt.show()
6✔
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