<jupyter_start><jupyter_text>Displaying coloured isolines 2With **Rainbow method** we can control the style of the lines. We can give it list of custom colours, thickness' and styles.  If there is not enough elements in the list, we can tell Magics to either repeat the last one or cycle them. In this one cell example notebook, we're using  for **contour_level_selection_type = "count"**, so instead of giving Magics the interval for levels, we give number of levels we want.  Installing MagicsIf you don't have Magics installed, run the next cell to install Magics using conda.<jupyter_code># Install Magics in the current Jupyter kernel
import sys
!conda install --yes --prefix {sys.prefix} Magics
import Magics.macro as magics

#Setting the geographical area
projection = magics.mmap(
    subpage_map_library_area = "on",
    subpage_map_area_name    = "central_europe",
    subpage_clipping         = "on",
    page_id_line             = "off"
)

#Setting the coastline
coast = magics.mcoast(
    map_coastline_colour            = "grey",
    map_coastline_resolution        = "medium",
    map_coastline_thickness         = 2,
    map_coastline_land_shade        = "on",
    map_coastline_land_shade_colour = "RGB(0.25,0.25,0.25)",
    map_coastline_sea_shade         = "on",
    map_coastline_sea_shade_colour  = "black",
    map_grid_line_style             = "dash",
    map_grid_colour                 = "grey"
)

#Loading GRIB file
temperature = magics.mgrib(grib_input_file_name = "../../data/t850.grib")

#Defining the contour
t_cont = magics.mcont(
    contour_label                              = "off",
    legend                                     = "on",
    contour_level_selection_type               = "count",
    contour_level_count                        = 41,
    contour_min_level                          = -20,
    contour_max_level                          = 20,
    contour_highlight                          = "off",
    contour_line_colour_rainbow                = "on",
    contour_line_colour_rainbow_method         = "list",
    contour_line_colour_rainbow_colour_list    = ['#053061', '#0c3d73', '#134a86', '#1a5899', '#2166ac', 
                                                  '#2b71b2', '#347cb8', '#3c88bd', '#4393c3', '#5a9fca', 
                                                  '#6eacd1', '#80b8d7', '#92c5de', '#a2cde3', '#b2d5e7', 
                                                  '#c2ddec', '#d1e5f0', '#dbe9f2', '#e4eef4', '#eef2f5', 
                                                  '#f7f7f7', '#f9f0eb', '#fbe9df', '#fce2d3', '#fddbc7', 
                                                  '#fccdb5', '#fac0a4', '#f7b293', '#f4a582', '#ed9474', 
                                                  '#e68367', '#de725a', '#d6604d', '#cd5144', '#c4413c', 
                                                  '#bb2f33', '#b2182b', '#9f1128', '#8c0a25', '#790422', 
                                                  '#67001f'],
    contour_line_thickness_rainbow_list        = [5,2,2,2,2,3,2,2,2,2],
    contour_line_thickness_rainbow_list_policy = "cycle"
)

#Defining the legend
legend = magics.mlegend(
    legend_display_type   = 'continuous',
    legend_text_colour    = "#2b619e",
    legend_box_mode       = "positional",
    legend_text_font_size = "0.45",
    legend_box_x_position = 20.00,
    legend_box_y_position = 0.3,
    legend_box_x_length   = 1.8,
    legend_box_y_length   = 17.3)

#Setting the title
title = magics.mtext( 
    text_lines          = ["Ploting rainbow isolines on black background",
                           "<grib_info key='name'/> -  STEP <grib_info key='step'/>",
                           "START TIME: <font colour='evergreen' style='bold'><grib_info key='base-date' format='%d %B %Y %H'/></font>   VALID TIME: <font colour='evergreen' style='bold'><grib_info key='valid-date' format='%d %B %Y %H'/></font>"],
    text_justification  = 'left',
    text_font_size      = 0.7,
    text_mode           = "automatic",
    text_colour         = "#2b619e") 

#Plotting
magics.plot(projection, coast, temperature, t_cont, legend, title)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11709319169483341, 'fraction_numerical': 0.046112988894253984, 'mean_word_length': 2.0262965668371073, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '237498', 'license': 'Apache-2.0', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1315, 'n_words': 294, 'path': 'visualisation/gallery/rainbow_lines2.ipynb', 'repo_name': 'mozartmae/notebook-examples', 'size': '4142'}