Exemple #1
0
"""
This is a basic example of how to use the library to create a boxplot in Python
"""
from graphy2.core import Graphy
from graphy2.StyleSheet import BLUE_ON_WHITE_GRID
import seaborn as sns

if __name__ == "__main__":

    # Load an example dataset from seaborn as the sample dataset
    data = sns.load_dataset("tips")

    # Modify a default style to have a smaller image size for a Non-print online only figure
    BLUE_ON_WHITE_GRID["dpi"] = 72

    # Call graphy2 to produce a box plot
    Graphy(data, "Box Plot", BLUE_ON_WHITE_GRID).box_plot(x_var="day",
                                                          y_var="total_bill")
Exemple #2
0
from graphy2.core import Graphy

if __name__ == '__main__':

    # Set the directory where your images are stored
    data = r"Path\To\Images"

    # Set the size to bound your images too, and then the 3D position of the camera that will view your graph
    Graphy(data, "Stacking Images").image_stack_figure(down_sampling=10,
                                                       elevation=15,
                                                       rotation=30)
Exemple #3
0
from graphy2.core import Graphy

if __name__ == '__main__':

    # Load in a csv with Labels, Amount, Explode columns
    read_data = r"C:\Users\Samuel\PycharmProjects\graphy2\ExampleData\Pie.csv"

    # Create the pie chart
    Graphy(read_data, "Pie Plot").pie_chart(display_values='%1.1f%%')
Exemple #4
0
    if file_only:
        return [file for file in os.listdir(directory) if os.path.isfile(f"{directory}/{file}")]
    else:
        return [file for file in os.listdir(directory)]

if __name__ == '__main__':

    # read_data = r"C:\Users\Samuel\PycharmProjects\graphy2\ExampleData\Binary_meta_event_total.csv"

    read_data = r"C:\Users\Samuel\PycharmProjects\AsthmaDisease\Testing"

    for index, file in enumerate(directory_iterator(read_data)):
        print(file)
        a = Path(read_data, file)
        if a.suffix == ".csv":
            Graphy(f"{read_data}/{file}", f"A{index}").forest_plot()


    # Graphy(f"{read_data}/base_forest.csv", "scarlet").forest_plot()
    # Graphy(f"{read_data}/sc_cont.csv", "sc_cont").forest_plot()
    # Graphy(f"{read_data}/sc_scarlet.csv", "sc_scarlet").forest_plot()
    # Graphy(f"{read_data}/sci_cont.csv", "sci_cont").forest_plot()
    # Graphy(f"{read_data}/sci_scarlet.csv", "sci_scarlet").forest_plot()
    # Graphy(f"{read_data}/sci_int.csv", "sci_int").forest_plot()
    # Graphy(f"{read_data}/sr_risk.csv", "sr_risk").forest_plot()
    # Graphy(f"{read_data}/sr_scarlet.csv", "sr_scarlet").forest_plot()
    # Graphy(f"{read_data}/sri_int.csv", "sri_int").forest_plot()
    # Graphy(f"{read_data}/sri_scarlet.csv", "sri_scarlet").forest_plot()
    # Graphy(f"{read_data}/sri_risk.csv", "sri_risk").forest_plot()
    #
    # Graphy(f"{read_data}/.csv", "AVbase_Forest").forest_plot()
Exemple #5
0
"""
This is a basic example of how to use the library to create a violinplot in Python
"""
from graphy2.core import Graphy

if __name__ == "__main__":

    import seaborn as sns
    import os

    # Load an example dataset from seaborn as the sample dataset
    data = sns.load_dataset("tips")

    # Get the path for the directory of this file, and save output to new sub-directory 'plots'
    write_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             "plots")

    # Call graphy2 to produce a box plot
    Graphy(data, write_dir).violin_plot(x_var="day",
                                        y_var="total_bill",
                                        gradient_variable="sex")
Exemple #6
0
from graphy2 import sys
from graphy2.core import Graphy

if __name__ == '__main__':
    # Rgraphy2 Null args don't get passed as system arguments, but False will be passed as a string rather than as a
    # bool so args needs formatting so that a False String returns a None type
    args = []
    for arg in sys.argv:
        if "FALSE" in arg:
            args.append(None)
        else:
            args.append(arg)

    try:
        function_name = args[1]
    except IndexError as e:
        raise Exception("No arguments passed to graphy_call.py") from e

    try:
        class_args = [args[i] for i in range(2, 6)]
    except IndexError as e:
        raise Exception("Not enough arguments passed to graphy_call.py for the class args. Args should be:\n"
                        "[0]Script_name\n[1]class_method_name\n[2]path_to_data_file\n[3]write_directory\n"
                        "[4]figure_name\n[5]style_sheet\n[6+]args for class_method_name")

    method_args = [args[i] for i in range(6, len(args))]

    getattr(Graphy(*class_args), str(function_name))(*method_args)
Exemple #7
0
"""
This is a basic example of how to use the library to create a lineplot in Python
"""
from graphy2.core import Graphy
import seaborn as sns

if __name__ == "__main__":

    # Load an example dataset from seaborn as the sample dataset
    data = sns.load_dataset("fmri")

    # Call graphy2 to produce a line plot
    Graphy(data, "Line Plot").line_plot(x_var="timepoint", y_var="signal")
Exemple #8
0
"""
This is a basic example of how to use the library to create a kdeplot in Python
"""
from graphy2.core import Graphy
import numpy as np
np.random.seed(10)
import pandas as pd
if __name__ == "__main__":

    import seaborn as sns
    import os

    # Load an example dataset from seaborn as the sample dataset
    mean, cov = [0, 2], [(1, .5), (.5, 1)]
    x, y = np.random.multivariate_normal(mean, cov, size=50).T
    data = pd.DataFrame({'X': x, 'Y': y}, columns=['X', 'Y'])

    # Get the path for the directory of this file, and save output to new sub-directory 'plots'
    write_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             "plots")

    # Call graphy2 to produce a box plot
    Graphy(data, write_dir).kde_plot()
"""
This is a basic example of how to use the library natively in python.
"""
from graphy2.core import Graphy

if __name__ == "__main__":

    # Set the file path
    csv_path = "./Path/to/your/file.csv"

    # Set where to save your file
    write_dir = "./Save/Directory"

    # Call graphy2's Graphy for the graph you want
    Graphy(csv_path, write_dir).scatter_plot("carat", "price", "clarity",
                                             "depth")
Exemple #10
0
"""
This is a basic example of how to use the library to create a barplot in Python
"""
from graphy2.core import Graphy

if __name__ == "__main__":

    import seaborn as sns
    import os

    # Load an example dataset from seaborn as the sample dataset
    data = sns.load_dataset("tips")

    # Get the path for the directory of this file, and save output to new sub-directory 'plots'
    write_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             "plots")

    # Call graphy2 to produce a box plot
    Graphy(data, write_dir).bar_plot(x_var="sex",
                                     y_var="total_bill",
                                     gradient_variable="smoker")