Get startedGet started for free

Side-by-side revenue box plots with color

The New York Stock Exchange firm you did work for previously has contracted you to extend on 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

This exercise is part of the course

Introduction to Data Visualization with Plotly in Python

View Course

Exercise instructions

  • Create a dictionary to map the different Industry values to the RGB codes noted above.
  • Create a box plot of revenues, setting the y-axis to be the company revenue.
  • Use the industry color map you created in the box plot construction.
  • Set the appropriate column for the color variable.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create the industry-color map
ind_color_map = {'Tech': ____, ____: ____, 
                 ____: ____, ____: ____}

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

# Show the plot
fig.show()
Edit and Run Code