Skip to main content

First upload of this package

Project description

Kiel Institute Design Template

This Design Template allows you to automatically apply the corporate design of the Kiel Institute for the World Economy to Matplotlib charts. It handles custom fonts, specific color palettes, and layout requirements to ensure that visualizations are publication-ready.

Prerequisites

To use this module effectively, you need to ensure that the following files and libraries are installed.

1. Python Libraries

This module requires matplotlib and cycler. If you do not have them installed, run the following command into the terminal or command prompt:

pip install matplotlib

Usually the cycler module is included in matplotlib. If it wasn't installed in the previous step run the following command aswell:

pip install cycler

2. Font Files

The Kiel Institute fonts are all from the 'Suisse' font familly. Usually the required fonts should be preinstalled on all Kiel Institute devices. If that is not the case, or if you are using your own device, please install the 'Suisse' fontkit.

3. Python Version

It is recomended that you use Python 3.11 for this template. For newer or older versions functionality is not guaranteed.

Installation

Type the following command into the terminal or command prompt:

pip install KI_Inst_design_template

Functionalities

This template has three functionalities, that will be introduced and shortly explained in the following.

1. Show Kiel Colours

The Colour Pallette of the Kiel Institute Brand Colours can be displayed by calling the show_kiel_institute_colors()-function in a python script:

from KI_Inst_design_template import show_kiel_institute_colors

show_kiel_institute_colors()

This opens a window, where the available colors and the names by which they can be accessed are displayed, aswell as their corresponding HEX-codes.

2. Initialize Design Template

The corparate design of the Kiel Institute can be applied globally to matplotlib, by calling the init_kiel_institute_theme-function:

from KI_Inst_design_template import init_kiel_institute_theme

init_kiel_institute_theme()

This applies the visual theme of the Kiel Institute to your plot.

3. Save charts in a file

Figures generated with Matplotlib can be saved in full compliance with the Kiel Institute's official layout guidelines:

from KI_Inst_design_template import save_kiel_institute

save_kiel_institute(fig, ax, filename, title, source, subtitle, description,
                                    footer, "vertical")

It is required, that a ==filename==, ==title== and ==source== are passed to the function as arguments in addition to the ==figure== (fig) and ==axes== (ax) objects. Specifying the other arguments is optional.

Example Usage

This is an example usage of the template with data form the GREIX:

from Ki_Inst_design_template import *

show_kiel_institute_colors()

init_kiel_institute_theme()

df = pd.read_csv("Mietpreisindex_jährlich.csv", sep=";")
df_real = df[df['real_nominal_str'] == 'Real']

# Define a specific color map for the cities using the "KIEL_COLORS" variables
# This ensures consistent branding/coloring across charts
city_color_map = {
    "Berlin": KIEL_COLORS["kiel_blue"],
    "Aachen": KIEL_COLORS["kiel_orange"],
    "Düsseldorf": KIEL_COLORS["kiel_green"],
    "München": KIEL_COLORS["kiel_red"],
    "Hamburg": KIEL_COLORS["kiel_turquoise"],
    "Kiel": KIEL_COLORS["kiel_pink"],
    "Köln": KIEL_COLORS["kiel_purple"]
}
cities = list(city_color_map.keys())

df_filtered = df_real[df_real['Value-Column Titles'].isin(cities)]
df_filtered_pivot = df_filtered.pivot(index='Year', columns='Value-Column Titles', values='Values')

# Initialize the figure and axis for the line plot
fig, ax = plt.subplots()

# Plot the time-series data on the axis using the specific colors defined earlier
df_filtered_pivot.plot(ax=ax, color=city_color_map)

df_filtered_bar = df[df["Year"]==2024]
df_filtered_bar = df_filtered_bar[df_filtered_bar["Value-Column Titles"].isin(cities)]
df_pivot_bar = df_filtered_bar.pivot(index="Value-Column Titles", columns="real_nominal_str",values="Values")

# Initialize the figure and axis for the bar plot
fig_bar, ax_bar = plt.subplots()

# Plot the "Nominal" and "Real" data on top of each other and specify the coloring using "KIEL_COLORS"
b1 = ax_bar.bar(df_pivot_bar.index,df_pivot_bar["Real"], label="Real Index", color=KIEL_COLORS["kiel_blue"])
b1 = ax_bar.bar(df_pivot_bar.index,df_pivot_bar["Nominal"], bottom=df_pivot_bar["Real"], label="Nominal Index", color=KIEL_COLORS["kiel_blue_60"])

# Add a legend to the bar chart if it isn't done automatically
ax_bar.legend()

# Use the save_kiel_institute function to save the charts in a .png file

save_kiel_institute(
    fig_bar,
    ax_bar,
    "bar_plott.png",
    title="Rental Price Index: Nominal vs. Real",
    source="subtitle subtitle subtitle subtitle subtitle subtitle subtitle",
    footer="https://www.kielinstitut.de/de/institut/forschungszentren/makrooekonomie/makrofinanzen/mietpreisindex/",
    description="description description description description description description description description" \
    " description description description description description description description description description description"
)

save_kiel_institute(
    fig,
    ax,
    "graph.png",
    title="Rental Price Development In German cities over time",
    subtitle="subtitle subtitle subtitle subtitle subtitle subtitle subtitle",
    footer="https://www.kielinstitut.de/de/institut/forschungszentren/makrooekonomie/makrofinanzen/mietpreisindex/",
    description="description description description description description description description description" \
    " description description description description description description description description description description",
)

Support

If you experience any difficulties with the template's functionality, we encourage you to submit an issue via GitHub. We will try to resolve the matter as quickly as possible.

License

This project is licensed under an All Rights Reserved License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ki_inst_design_template-0.0.1.tar.gz (78.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ki_inst_design_template-0.0.1-py3-none-any.whl (79.4 kB view details)

Uploaded Python 3

File details

Details for the file ki_inst_design_template-0.0.1.tar.gz.

File metadata

  • Download URL: ki_inst_design_template-0.0.1.tar.gz
  • Upload date:
  • Size: 78.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for ki_inst_design_template-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d6188528bb0624f23ba81659df6f383348525b90d4890729262f8341ae188985
MD5 756d6650e02da9b73e9bf9da998426da
BLAKE2b-256 a6f4a2316c1677030a8dec9118d3cc23bae3d3bb5a5316b6b3b0aee2cbafc81a

See more details on using hashes here.

File details

Details for the file ki_inst_design_template-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ki_inst_design_template-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b361dbe3f3248a2c9edec8cb038cd19b3b0e2f4894f4203297bbc4e8c5bf967d
MD5 45fb1b29b5e68bca9686752f115f9e73
BLAKE2b-256 4c025f262c1207320b7389f4d29ac43dfe31bec01d30ef4c3d80639b57f6a550

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page