LoslegenKostenlos loslegen

Side-by-side revenue box plots with color

The New York Stock Exchange firm you previously worked for has contracted you to extend your work building the box plot of company revenues.

They want to understand how different industries compare using this same visualization technique from before. They are also particular about what colors are used for what industries. They have prepared a list of industries and the colors as below.

Your task is to create a box plot of company revenues, as before, but include the specified colors based on the list of industries given below.

There is a revenues DataFrame already loaded for your use.

Industry-color RGB definitions:

  • Tech = 124, 250, 120
  • Oil = 112,128,144
  • Pharmaceuticals = 137, 109, 247
  • Professional Services = 255, 0, 0

Diese Übung ist Teil des Kurses

Introduction to Data Visualization with Plotly in Python

Kurs anzeigen

Anleitung zur Übung

  • Create a dictionary mapping each Industry to its RGB color.
  • Create a box plot of revenues, using Revenue as the y-axis.
  • Apply your industry color map to the plot.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Create the industry-color map
ind_color_map = {"Tech": ____, "Oil": ____, 
                 "Pharmaceuticals": ____, "Professional Services": ____}

# Create a box plot
fig = px.____(
  			# Set the data and y variable
  			data_frame=____, y="____",
  			# Set the color map 
			____=____,
			color="Industry")

# Show the plot
fig.show()
Code bearbeiten und ausführen