Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code to reproduce JOSS figure #140

Merged
merged 6 commits into from
May 15, 2024
Merged

Conversation

FLomb
Copy link
Contributor

@FLomb FLomb commented May 8, 2024

JOSS's reviewers asked for the inclusion of the code to reproduce the illustrative Figure we have in the paper (see: openjournals/joss-reviews#6418 (comment)). This PR addresses this.

However, the PR is currently based on the old plotting functionality with some customisation. As discussed during RAMP's development meetings, it'd be better to produce a similar Figure with the newest plotting functionality. I tried doing so via the shadow plot functionality, but I struggled to customise it to the degree needed. For example, I did not manage to pass kwargs related to the ax object or to the colours of the lines. Perhaps @mohammadamint may know how to do it. If not possible, we may as well stick to this custom code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this file ended up in the commit; I shouldn't have changed anything there and for some reason git diff does not return any difference between my commit and the joss-paper branch for this file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently the image generated must be slightly different, this is the only line highlighted (once you commited git diff will not show the diff anymore), you can do git diff HEAD~1 to get the diff of the last commit.

@Bachibouzouk
Copy link
Collaborator

You can use

uc = UseCase("JOSS-paper-figure", users=[LMI, LI])
uc.initialize(num_days=1)
plot = uc.generate_daily_load_profiles(
    cases=[1,2,3,4,5]
)
plt.rcParams.update({'font.size': 22})

fig, ax1 = plot.shadow( figsize=(16, 8))
ax1.legend(['5-day average', 'Single days(s)'])
ax1.margins(0)

ax1.set_xticks(ax1.get_xticks()[1:])
import matplotlib.dates as mdates
myFmt = mdates.DateFormatter('%H:%M')
ax1.xaxis.set_major_formatter(myFmt)

ax1.set_ylabel('Normalised power (kW/kW-Peak)', fontsize='large', labelpad=20)
ax1.set_xlabel('Time (hours:minutes)', fontsize='large', labelpad=20)

To generate a figure similar using the new plotting capabilities

@mohammadamint
Copy link
Collaborator

You can use

uc = UseCase("JOSS-paper-figure", users=[LMI, LI])
uc.initialize(num_days=1)
plot = uc.generate_daily_load_profiles(
    cases=[1,2,3,4,5]
)
plt.rcParams.update({'font.size': 22})

fig, ax1 = plot.shadow( figsize=(16, 8))
ax1.legend(['5-day average', 'Single days(s)'])
ax1.margins(0)

ax1.set_xticks(ax1.get_xticks()[1:])
import matplotlib.dates as mdates
myFmt = mdates.DateFormatter('%H:%M')
ax1.xaxis.set_major_formatter(myFmt)

ax1.set_ylabel('Normalised power (kW/kW-Peak)', fontsize='large', labelpad=20)
ax1.set_xlabel('Time (hours:minutes)', fontsize='large', labelpad=20)

To generate a figure similar using the new plotting capabilities

@Bachibouzouk Thanks :-). Sorry for my delay in replying!

@FLomb
Copy link
Contributor Author

FLomb commented May 8, 2024

Ok, thanks for your guidance. I've updated the figure accordingly. What we get is an almost identical result, except for colours. I reckon there's no way to change the colours of the shadow function because they are hardcoded, aren't they? Should I commit a change to the function that allows for colour customisation, too?

@Bachibouzouk
Copy link
Collaborator

function because they are hardcoded, aren't they?

You can get the plotted lines from the axis handle
https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.axes.Axes.get_lines.html

@FLomb
Copy link
Contributor Author

FLomb commented May 14, 2024

function because they are hardcoded, aren't they?

You can get the plotted lines from the axis handle https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.axes.Axes.get_lines.html

Thanks for the tip! I've updated the code with custom colours. Now, the figure looks as expected; I should update the paper with it because it's still marginally different.

Copy link
Collaborator

@Bachibouzouk Bachibouzouk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @FLomb this looks neat

I added a seed to the UseCase so the figure is reproducable

@Bachibouzouk Bachibouzouk merged commit fbf77bd into joss-paper May 15, 2024
3 checks passed
@Bachibouzouk Bachibouzouk deleted the review/paper-figure-code branch June 24, 2024 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants