I'm running a lot of simulations in the field of electrical systems using PSS/E. Currently, I'm on the phase of treating the captured data to visualize it.
I have already investigated over the Internet. I've also seen a lot of examples on how to build different plots using ggplot in python, but none of those tutorials or examples seem to care much about the dataframe construction.
The following code does plot a chart as expected for me.
def plot_default_example(self):
islands = ['LPA', 'LPA', 'LPA', 'LPA', 'LPA', 'LPA',
'TNF', 'TNF', 'TNF', 'TNF', 'TNF', 'TNF',
'GOM', 'GOM', 'GOM', 'GOM', 'GOM', 'GOM']
years = [2014, 2015, 2016, 2017, 2018, 2019,
2014, 2015, 2016, 2017, 2018, 2019,
2014, 2015, 2016, 2017, 2018, 2019]
population = []
for _ in range(0, 18):
population.append(randint(1500, 15000))
print years
print population
df = pd.DataFrame({'island': islands, 'years': years, 'population': population})
plt = ggplot(df, aes(x='years', y='population', color='island')) +\
geom_line() + labs(title='Random Population in 3 of the Canary Islands from 2014 to 2019')
print plt
As you might realize, in the dataframe there is a lot of redundant because the years and islands are repeated, but it is the only way I know how to do it.
I was wondering if there is any way to avoid such redundancy.
Thanks for any help you can provide.

