from pyCreeper import crGraphs;
from pyCreeper import crGraphStyle;
crGraphs.BASE_FILE_PATH = "../../exampleOutput/";
[docs]def example1_simple(saveFiles_):
"""
In this example, a simple pie chart is created:
.. image:: ../exampleOutput/pieChart_simple.png
:scale: 50%
:param saveFiles_: Boolean if True, figures are saved, if False, figures are displayed
"""
expenseCategories = ["Rent", "Food", "Travel", "Fun"];
expenses = [1000, 300, 500, 250];
filePath = "";
if (saveFiles_):
filePath = "pieChart_simple.png";
crGraphs.createPieChart(expenses, expenseCategories,filePath_=filePath);
[docs]def example2_colors(saveFiles_):
"""
In this example, the title, colors and font sizes are specified. Percentage values and actual values are also shown:
.. image:: ../exampleOutput/pieChart_colors.png
:scale: 50%
:param saveFiles_: Boolean if True, figures are saved, if False, figures are displayed
"""
expenseCategories = ["Rent", "Food", "Travel", "Fun"];
expenses = [1000, 300, 500, 250];
style = crGraphStyle.crGraphStyle();
style.colors = ['yellow','cyan','grey','white'];
crGraphs.setStyle(style);
filePath = "";
if (saveFiles_):
filePath = "pieChart_colors.png";
crGraphs.createPieChart(expenses, expenseCategories, "Colors example", showPercentageVals_=True, showShadow_=True, filePath_=filePath);
if __name__ == "__main__":
saveFiles = True;
example1_simple(saveFiles);
example2_colors(saveFiles);
example3_multiFigure(saveFiles);