File size: 1,414 Bytes
678a0d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

class plotting():
    def quick_plot(self, scatter=None, line=None, columns=["X","Y"], output=None, hline=None):
        """
        Plot the data along with the best fit line and its associated confidence band.

        Parameters:
            data (list): List of data to plot
            columns (list): Axes labels (default is "X","Y")

        Returns:
            None: Displays a matplotlib plot with data, fit line, and confidence band

        Example:
            >>> quick_plot(x_data, y_data)
        """

        if scatter is None and line is None:
            raise ValueError("Either scatter or line should be provided")
        
        if not isinstance(scatter,list):
            scatter = [scatter]
        if not isinstance(line,list):
            line = [line]

        # Plot the observed data points as a scatter plot
        for ds in scatter:
            plt.scatter(ds[:,0],ds[:,1], color='blue', label='Data')

        # Add labels and title to the plot
        plt.xlabel(columns[0])
        plt.ylabel(columns[1])
        
        if hline is not None:
            plt.axhline(hline, color='black', linestyle='--')

        # Display the legend
        plt.legend()

        # Show the plot
        if output is None:
            plt.show()
        else:
            plt.savefig(output)
        plt.close()