Cognite Charts: Figure element formatting for export

Related products: Charts

I have been involved in a root cause analysis lately, and we are not working on the final report. I have been asked to produce a couple of trends, and my go-to tool was Charts. While there is a PNG export functionality, I find it so limiting that I ended up in Python and matplotlib to produce a decent looking figure of a simple differential pressure time series.

Some of the things I am missing

  • Possibility to set font sizes of x and y labels
  • Set a figure title (displayed on top of the figure)
  • How detailed the x ticks and x tick labels should be. The user should be able to set the time interval, either with a dropdown of preset choices, or a custom string formatting option for “pro” users (“%Y-”b”) to produce labels of the form “2021-Jan”.
  • More colors to choose from, and to set the hex manually (I especially miss “black”).
  • To change the figure aspect ratio and dpi.
  • To set the background color to a dark color.
  • A legend should be autogenerated based on the currently visible time series (name and formatting). The user should be allowed to set the position.

 

I have attached Matplotlib’s great figure “Anatomy of a figure” for reference :) 

 

Regards,

Anders

 


Here is a screenshot of a PNG export in Charts. It is in practice just a screenshot of the Charts interface. 

  • The list of TSs is not relevant, and especially not the invisible TSs.
  • The labels are too small and have a too low contrast
  • I would like to change the granularity of the displayed TS to show some peaks that are hidden by the averager.
  • Legend missing
  • Difficult to check a value for one month, since the tick labels are year only.

 


As a comparison, here is a figure made in Python with matplotlib.

 


tag2 = "pi:112558"
tag1 = "pi:112556"

start = datetime(2016, 1, 1)
end = datetime(2022, 11, 1)
granularity = "1d"

data = client.datapoints.retrieve(external_id=[tag1, tag2], start=start, end=end, granularity=granularity, aggregates=["average"]).to_pandas()
data.columns = ["Upstream", "Downstream"]
data["dP"] = data.Upstream - data.Downstream

fig, ax = plt.subplots(figsize=(7, 3), dpi=200)

ax.plot(data.dP, color="black", lw=1, label="dP (1d avg)")
ax.axvline(datetime(2020, 11, 11), color="salmon", ls="-", lw=0.75, label="Endring til ~61 bar", zorder=1)

ax.grid(ls=":", lw=0.5)
#ax.set_ylim(40, 65)
#ax.set_xlabel("Dato")
ax.set_ylabel("dP (bar)")
ax.tick_params("x", labelrotation=45)
ax.set_xticklabels(ax.get_xticklabels(), ha="right")
ax.legend(bbox_to_anchor=(0.5, 1.0), loc="lower center", ncol=2)

ax.xaxis.set_major_locator(mdates.MonthLocator(interval=6))
ax.xaxis.set_major_formatter(mdates.DateFormatter("%Y-%b"))

fig.tight_layout()
fig.savefig("dP_first_stage_separator.png")

 


Thanks @Anders Brakestad for taking the time to provide these examples and best practices! You’re absolutely right that we can (and should) have a more robust image exporting experience when you want to make your charts report/ presentation-ready. 

@Magdalena Rut FYI for some great suggestions and benchmarks for improving this feature. 


NewGathering Interest