1

O. community. Long time lurker, first time posting.

Consider stacked area charts that are made up of the sum of individual curves. I am trying to create 'optimized' stacked area charts in python that iterate individual curves along the x-axis within given constraints to find a minimum area, minimum slope, or minimum peak.

My x-axis data is time and y-axis data are headcount resources for a given project. This will help find the minimum number of resources needed on co-current projects by varying the start times.

Here's my starter code with example data (not much I know), but just to illustrate:

import pandas as pd
import matplotlib.pyplot as plt


data = {'Project_1':[0,25,36,14,2],
        'Project_2':[2,78,45,11,1],
        'Project_3':[25,16,59,8,0]}

df = pd.DataFrame(data)

ax = df.plot.area()
plt.show()

I'd like to set 2-constraints for each project of when each project needs to start (minimum time and max time). For example:

Project 1: Time 1 >= x1 > Time 2 (project 1 must start at or later than Time 1 and before Time 2) Project 2: Time 4 > x2 > Time 4 Project 3: x3 = x1 (ie- project 3 must start the same time as project 1)

Once those are set, the curves would iterate (for loop?) along their given constraints to find the minimum total area, or minimum slope (ie- closest to a flat line), or minimum peak. Any of these solution optimizations are OK, and the ability to choose the solution would be bonus points. There also might be an interesting solution trying to minimize the total curve length(?).

The output would be:

  1. A graph like the one shown, or multiple if there are multiple solutions (maybe top 3 best)
  2. The starting times for x1,x2,x3, etc

Any help, tips, etc on this would be appreciated! Thank you so much!

I've tried searching for iterating curves and stacked area charts with little success. I included some basic code for illustration. I'm a little stumped on this one... enough to try stack overflow for the first time!

  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Oct 29 '22 at 03:56

0 Answers0