Skip to content
Programs · Program 4-5

Q.(Program 4-5) Assuming the same CSV file, i.e., MelaSales.CSV, plot the line chart with following customisations: Marker = "*", Marker size = 10, linestyle = "--", Linewidth = 3. Also substitute the x-axis ticks with the corresponding Day names using plt.xticks().

Rajasthan RbseTextbookSubjective· 4mImportance★★★★★est
18% · 8/44 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Style the same line chart: markers, thicker dashed lines, and day names on the x-axis.

import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_csv("MelaSales.csv")
df.plot(kind='line', color=['red','blue','brown'], marker="*", markersize=10, linewidth=3, linestyle="--")
plt.title('Mela Sales Report')
plt.xlabel('Days')
plt.ylabel('Sales in Rs')
ticks = df.index.tolist()
plt.xticks(ticks, df.Day)
plt.show()

Styling parameters (marker, markersize, linewidth, linestyle) are passed straight to df.plot(); plt.xticks(ticks, df.Day) relabels the x-axis with the real day names instead of index numbers.

Step by step

  1. The same df.plot(kind='line', ...) call as Program 4-4, now with four extra style keywords: marker="*", markersize=10, linewidth=3, linestyle="--".
  2. By default the x-axis would still show the DataFrame's row-number index (0-6). ticks = df.index.tolist() grabs those same positions, and …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.