I am trying to plot stuff using matplotlib and mpld3. This is the code I use to generate my graph:
_fig = plt.figure()
_pl = _fig.add_subplot(111)
_pl.plot(_times, _values)
_pl.set_xlabel("Time")
_pl.set_ylabel("Value")
_pl.tick_params(direction="out", axis="both", colors="white", which="both")
_pl.xaxis.label.set_color("white")
_pl.yaxis.label.set_color("white")
_data = mpld3.fig_to_html(_fig)
.... send to client to be rendered
A graph is created and all the dynamic controls work. "Time" and "Value" labels get printed in white but tick labels in black.
If I skip mpld3 and test it with plt.show(), all tick labels get printed in white. When I check the javascript code generated by mpld3, I do not seem to detect the colour setting there for tick labels.
If I use another parameter, like font size, in tick_params it does have an effect. Only the colour gets ignored, which causes the labels to be printed in black on a dark blue background.
How do I change this?
Edit:
When inspecting the actual page rendered, there seems to be a "fill" property that determines the colour.
div#fig_el249691400950908834083380374260 .mpld3-xaxis text
{font-family:sans-serif; font-size:10px; fill:black; stroke:none; }
I tried overriding this in css but I could not figure out how to do it. This seems to override whatever I set elsewhere. It appears mpld3 sets the colour of the tick label, but how do I modify this?
Hannu
mpld3 only supports a subset of matplotlib's full capabilities, and tick formatting is one of the many things that is not yet supported. There is a partial list of these missing features on the mpld3 wiki.
Related
I'm looking for a solution in which custom text is rendered instead of a point for a scatter or bubble diagram using chart.js. For example, if plotting baseball players' batting average vs slugging percentage, I want the player's name to appear centered horizontally and vertically over the underlying x,y coordinate, such as 'MANTLE' or 'RUTH', instead of the typical dot/square/triangle/bubble pointstyles. I noticed a callback function lets me program custom axis labels, but I need to do something similar for the actual point of the graph.
If this is not possible, can you recommend another library that can do this.
Thank you in advance...
chartjs-plugin-datalabels does what you're looking for. The positioning of the labels is largely customizable. A custom label formatter function for example lets you display text other than the data values.
Please take a look at the chartjs-plugin-datalabels samples, especially at Custom Labels.
Keep in mind that this plugin registers itself globally, meaning that once imported, all charts will display labels. In case you want it enabled only for a few charts, you first need to unregister it globally. Then, you can enabled the plugin for specific charts.
I have a Qt application that I am porting to mac.
There are some objects (images) shown in QListView or QTableView, in IconMode, that, when selected, in Windows and Linux get highlighted (a rectangle holding the object, which has colored background - gray if the item is selected but no focus, light blue if the item has focus, slightly more intense blue if the item is selected and has focus - this is probably the default behavior for selection, based on selected color scheme).
On mac the only thing that shows is a tiny dot under the object, and if the object in the view is transparent, light blue shows inside the object - but no selection rectangle. Nothing changes if the object has focus, and if the object is not transparent, only the tiny dot under the object shows.
Once objects are moved on the canvas, mac shows selection as needed, on a bounding rectangle, only inside the listview and tableview the bounding rectangle is invisible.
The form was created using the Designer... the listView property QListView.selectionRectVisible is checked.
I can't see what makes that happen... but I have tried
#if defined (Q_OS_MACX)
m_ui->lv1->setAttribute(Qt::WA_MacShowFocusRect, true);
m_ui->lv1->UseCustomSelectionColors(true); // documentation shows this but it doesn't build
m_ui->lv1->setSelectionRectVisible(true);
#endif
for the mac, and it does not make any difference.
What else can I try, to show selection of objects ?
Qt 4.8
Edit: found a site that has an example for a tiled list view... among other things it draws a visible rectangle around the selected items...
It seems like a very complicated way to do something that seems to be already implemented - highlighting a selected object - I will do it if I have to but I am hoping that I do not have to add something too complicated for the mac version, that will not be used in any other platforms...
There has to be a way to use the normal properties and methods of listview and tableview to make sure that the background of the bounding rectangle, not just the background of the item, shows when a selection is made ?
I don't know if this is a typical mac behavior...
Update
While I really try not to overwrite the desired default system behavior, I tried to force list behavior...
#if defined (Q_OS_MACX)
QString stylesheet = "";
stylesheet += "QListView::item:selected:active:hover{background-color:red;}";
stylesheet += "QListView::item:selected:active:!hover{background-color:blue;}";
stylesheet += "QListView::item:selected:!active{background-color:yellow;}";
stylesheet += "QListView::item:!selected:hover{background-color:green;}";
setStyleSheet(stylesheet);
#endif
The problem is, I need the system colors, I cannot define my own since they will not match the rest of the app window...
What are the names of the system colors for hover, select (strong), select (but no focus), select (but not active) ?
I have tried using
stylesheet += "QListView::item:selected:active:hover{background-color:Highlight;}";
In windows, this looks ok - because it probably is not recognized so it is ignored... On mac, still ignored. And I have not seen any other names for backgrounds. I tried it with lowercase as well.
I ended up using a style sheet - as in the update to my question - with hard-coded color values for the osx blue theme.
folks!
I use a listview (Icon mode) to display items which consist of an image and a label.
As you can see in the shots the row height is variable on y depending on the label length. The problem is that I want the complete labels to be drawn, but they are automatically shrinked into two lines:
The strange thing about it is that once you select an item the whole label will be shown:
This is also the case when deselecting the item, but when another item gets selected, only that one will be shown completely.
Is there a way (without drawing the text manually) to avoid truncation in my case?
If some code is needed to answer this question, don't hesitate to ask.
Greetings,
Satara
I'm guessing this was a design choice: make things look less cluttered. E.g. picture your desktop with all labels shown completely... will look messy in my case.
However, you can fix this by drawing the label yourself. Have a look into custom draw which is a service provided by the list control. The thing is that it's usually an all or nothing approach, so this will likely require you to draw everything yourself: border, image, label, etc. The other option is to get hacky: subclass the window and draw the labels again after Windows did in response to several messages (unfortunately Windows does not restrict the painting to WM_PAINT, an optimization that is a left-over from the old days...)
Within my GUI (C++, GTKMM 3), i have a text field that is providing some status information. i'd like to change the background color of this field (along with the text, which i can easily do), based upon the status.
there's not a lot out there on how to do this with GTKMM 3.X. i know i need to use the CssProvider class, and have found some examples on how to load one into the program. but the examples show how to set the properties one time.
but what i haven't figured out is how i can use the CSS properties to change the color of the background, based upon a state (not a state as in 'hover' or anything like that. i want to be able to swap the background from red to green whenever i please). if the CSS is written in terms of using the name of the widget, or the type of widget, how do you handle a changing state with the widget to change its properties?
if anyone has any clues, or knows of any examples, i could really use some help. the purpose of this is to give the user some immediate feedback at a glance. in a rush, they won't have to read the status of the box (or from a distance). the color will allow them to gauge what is going on at a glance.
Adding code
this is what i have tried so far (condensed):
std::string style_sheet = ".red_bg {background: #FF0000; color: #000000; } ";
style_sheet += ".green_bg {background: #33FF33; color: #000000; }";
Glib::RefPtr<Gtk::StyleContext> stylecontext = my_text_field->get_style_context();
Glib::RefPtr<Gtk::CssProvider> cssprov = Gtk::CssProvider::create();
cssprov->load_from_data(style_sheet);
stylecontext->add_provider(cssprov, GTK_STYLE_PROVIDER_PRIORITY_USER);
stylecontext->add_class("red_bg");
stylecontext->context_save();
so that works. when the program fires up, i get a text entry with a red background.
but later on, if i do the following, nothing happens:
Glib::RefPtr<Gtk::StyleContext>stylecontext = my_text_field->get_style_context();
stylecontext->remove_class("red_bg");
stylecontext->context_save(); // probably not necessary
stylecontext->add_class("green_bg");
stylecontext->context_save();
at that point, the background stays red. no transition from red to green. i've seen suggestions to use the override_background_color function in the GtkWidget object, but that doesn't work. that only changes the color that is used when you highlight the text in the widget. i'd still like to see it done the CSS way.
You could do away with the CSS and just use override_background_color, a standard GTK widget method:
override_background_color (StateFlags state, RGBA color)
Sets the background color to use for a widget.
All other style values are left untouched.
Note:
This API is mostly meant as a quick way for applications to change a widget appearance. If you are developing a widgets library and intend this change to be themeable, it is better done by setting meaningful CSS classes and regions in your widget/container implementation through add_class and add_region.
This way, your widget library can install a CssProvider with the STYLE_PROVIDER_PRIORITY_FALLBACK priority in order to provide a default styling for those widgets that need so, and this theming may fully overridden by the user's theme.
Note:
Note that for complex widgets this may bring in undesired results (such as uniform background color everywhere), in these cases it is better to fully style such widgets through a CssProvider with the STYLE_PROVIDER_PRIORITY_APPLICATION priority.
Parameters:
StateFlags state the state for which to set the background color
RGBA color the color to assign, or null to undo the effect of previous calls to override_background_color
I'm trying to automate some PowerPoint charts, but I'm having problems preserving some formatting.
When I add a chart using a chart template, the chart doesn't use the slides color scheme, but rather the colors it was saved with. It doesn't help to change the color scheme for the slide - the chart isn't updated. To make the chart update to the color scheme of the slide, I have to clear formatting for the chart. The problem with doing this is that all font sizes are automatically set to 18pt. I cannot find any easy way restore the font sizes for the chart without saving all sizes before calling clear, and set them back after clearing.
Have you looked into using the Format Painter function it may or may not work depending on a variety of factors from my quick look on the net (google it for lots of articles).
Also if you've done one chart you should be able to copy the formatting from one chart to another using the paste special option as mentioned here http://www.pcreview.co.uk/forums/there-format-painter-equivalent-use-many-charts-t3611646.html .