How can you change font for parts of the plot?
I'm sure there's an obvious answer to this, but how do I change the font for a specific portion of the plot? Pushing normalFont in the following is completely ignored and the same font is used throughout the plot. I actually only want to set the header independent of the axes, but I failed before I even got that far... It seems odd to me that imgui doesn't pass fonts as part of it's style struct, but I guess an alternative question is: How can I access the plot dimensions so I can hide the plot text and use the main imgui code to draw the text (if it's not possible to do from within implot)?
if (ImGui::CollapsingHeader("Multiple Fonts")) {
ImFont* normalFont = ImGui::GetIO().Fonts->Fonts[0];
ImFont* headerFont = ImGui::GetIO().Fonts->Fonts[3];
ImGui::PushFont(headerFont);
int data[2] = { 0,1 };
if (ImPlot::BeginPlot("Plot A", "x-label", "y0-label")) {
ImGui::PushFont(normalFont);
ImPlot::PlotLine("Line", data, 2);
ImGui::PopFont();
ImPlot::EndPlot();
}
ImGui::PopFont();
}
All text is rendered inside of BeginPlot (title/axes) or EndPlot (legend). There is currently no way to setup different fonts for different elements of the plot.
If you want to render the header yourself, you can hide the default by prepending ## on the label ID.