- Enclose with " for exact match e.g., "uitable report"
- Another couple of Matlab bugs and workarounds
- Plot markers transparency and color gradient
- Plot line transparency and color gradient
- Customizing axes part 4 – additional properties
- Customizing axes part 3 – Backdrop
- Customizing axes part 2
- Customizing axes rulers
- Customizing combobox popups
- Customizing listbox/combobox items
- savezip utility
- Inter-Matlab data transfer with memcached
- Property value change listeners
- Online (web-based) Matlab
- Class object tab completion & improper field names
- Desktop (35)
- Figure window (35)
- Guest bloggers (43)
- GUI (113)
- Handle graphics (58)
- Hidden property (32)
- Icons (7)
- Java (136)
- Listeners (17)
- Memory (12)
- Mex (9)
- Presumed future risk (274)
- Semi-documented feature (7)
- Semi-documented function (31)
- Stock Matlab function (103)
- Toolbox (2)
- UI controls (39)
- Uncategorized (9)
- Undocumented feature (134)
- Undocumented function (29)
TagsActiveX Callbacks COM Compiler Desktop Donn Shull Editor FindJObj GUI GUIDE Handle graphics HG2 Hidden property HTML Icons Internal component Java JavaFrame JIDE JMI keyboard Listener Malcolm Lidierth Matt Whitaker MCOS Memory Menubar Mex Performance Profiler Pure Matlab schema schema.class schema.prop scribe Semi-documented function Toolbar uicontrol UIInspect uitable uitools uiundo Undocumented feature Undocumented function Undocumented property
- nose holes (1 day 17 hours ago): Hi Yair, Couldn’t agree with you more about the unwillingness of TMW to acknowledge bugs. However, I think the support department is to blame for this. Once you get to...
- Mikhail (1 day 19 hours ago): Hi Yair, I share your frustration. This standard reply “consider fixing it in a future release of MATLAB” really demotivates me from reporting any further bugs....
- Alessandro (2 days 4 hours ago): Thank you very much. I really enjoyed this topic!
- Dan (2 days 6 hours ago): Yair, As always, thank you for your posts. I heartily agree with you about the frustrations with TMW’s bug list. I find it especially obnoxious that a whole slew of new bugs...
- Christian Beuschel (2 days 8 hours ago): I guess that my manipulation of the rowHeader by attaching a textarea, destroys everything. Before manipulation my object has Wrapping off. After manipulation there is...
- Christian Beuschel (2 days 10 hours ago): Hello, unfortunately it’s not true. I just tried by opening my programm directly with smaller figure width. I did not resize it after. The text is immediately...
- Yair Altman (2 days 15 hours ago): @Christian – when you resize a component, Matlab resets its internal Java properties, so your Java customizations are forgotten and need to be re-applied. Specifically,...
- Christian Beuschel (2 days 18 hours ago): Here a screenshot to show my problem a little better. I am attaching a small textarea to the jHandle of the editfield to see the number of lines. but when i resize the...
- Michael (3 days 8 hours ago): As far as I can tell, changing the EdgeColorBinding (or FaceColorBinding) from ‘object’ to ‘interpolated’ or ‘discrete’ is problematic. Entering...
- Christian Beuschel (3 days 11 hours ago): Dear Mr. Altman, i got a problem with the setWrapping Function. It does not work. My Versions are: MATLAB Version: 184.108.40.2061 (R2013b) Java Version: Java 1.7.0_11-b21 When...
- Yair Altman (4 days 14 hours ago): h = area(magic(4)); % 1x4 area object set([h.Face], 'ColorType', 'truecoloralpha') h(2).Face.ColorData(4) = 90; % =90/255=35% opaque =65% transparent
- Grunde (4 days 14 hours ago): The area object doesn’t have any children. And the area object itself doesn’t have a FaceAlpha property. At least in 2014b.
- Yair Altman (4 days 15 hours ago): @Grunde – Yes this is possible, but I don’t think you need to use any undocumented features for this. Assuming you used the builtin area function to generate the...
- Grunde (4 days 16 hours ago): Is it possible to make the area plots transparent? Or do I have to use the patch command?
- Yair Altman (7 days 14 hours ago): @Christopher – this is because the flat header is used by the new (R2008a+) uitable, whereas the gradient-colored header is used by the “old” uitable...
Every now and then I come across some internal Matlab bugs. In many cases I find a workaround and move on, sometimes bothering to report the bugs to MathWorks support, but often not. In truth, it’s a bit frustrating to hear the standard response that the issue [or "unexpected behavior", but never "bug" - apparently that's a taboo word] “has been reported to the development team and they will consider fixing it in one of the future releases of MATLAB”.
To date I’ve reported dozens of bugs and as far as I can tell, few if any of them have actually been fixed, years after I’ve reported them. None of them appear on Matlab’s official bug parade, which is only a small subset of the full list that MathWorks keeps hidden for some unknown reason (is it possible that someone’s ashamed of their bugs? nuh, couldn’t be…). Never mind, I don’t take it personally, I simply find a workaround and move on. I’ve already posted about this before. Today I’ll discuss two additional bugs I’ve run across once-too-often, and my workarounds:
Nothing really earth-shattering, but annoying nonetheless.
Last week I explained how to customize plot-lines with transparency and color gradient. Today I wish to show how we can achieve similar effects with plot markers. Note that this discussion (like the preceding several posts) deal exclusively with HG2, Matlab’s new graphics system starting with R2014b (well yes, we can also turn HG2 on in earlier releases).
As Paul has noted in a comment last week, we cannot simply set a 4th (alpha transparency) element to the MarkerFaceColor and MarkerEdgeColor properties:
>> x=1:10; y=10*x; hLine=plot(x,y,'o-'); >> hLine.MarkerFaceColor = [0.5,0.5,0.5]; % This is ok >> hLine.MarkerFaceColor = [0.5,0.5,0.5,0.3]; % Not ok While setting the 'MarkerFaceColor' property of Line: Color value must be a 3 element numeric vector
Lost cause? – not in a long shot. We simply need to be a bit more persuasive, using the hidden MarkerHandle property:
In the past few weeks, I discussed the new HG2 axes Backdrop and Baseline properties with their associated ability to specify the transparency level using a fourth (undocumented) element in their Color.
In other words, color in HG2 can still be specified as an RGB triplet (e.g., [1,0,0] to symbolize bright red), but also via a 4-element quadruplet RGBA, where the 4th element (Alpha) signifies the opacity level (0.0=fully transparent, 0.5=semi-transparent, 1.0=opaque). So, for example, [1, 0, 0, 0.3] means a 70%-transparent red.
This Alpha element is not documented anywhere as being acceptable, but appears to be supported almost universally in HG2 wherever a color element can be specified. In some rare cases (e.g., for patch objects) Matlab has separate Alpha properties that are fully documented, but in any case nowhere have I seen documented that we can directly set the alpha value in the color property, especially for objects (such as plot lines) that do not officially support transparency. If anyone finds a documented reference anywhere, please let me know – perhaps I simply missed it.
Here is a simple visualization:
xlim([1,5]); hold('on'); h1a = plot(1:5, 11:15, '.-', 'LineWidth',10, 'DisplayName',' 0.5'); h1b = plot(1.5:5.5, 11:15, '.-', 'LineWidth',10, 'DisplayName',' 1.0', 'Color',h1a.Color); % 100% opaque h1a.Color(4) = 0.5; % 50% transparent h2a = plot(3:7, 15:-1:11, '.-r', 'LineWidth',8, 'DisplayName',' 0.3'); h2a.Color(4)=0.3; % 70% transparent h2b = plot(2:6, 15:-1:11, '.-r', 'LineWidth',8, 'DisplayName',' 0.7'); h2b.Color(4)=0.7; % 30% transparent h2c = plot(1:5, 15:-1:11, '.-r', 'LineWidth',8, 'DisplayName',' 1.0'); % 100% opaque = 0% transparent legend('show','Location','west')
Now for the fun part: we can make color-transition (gradient) effects along the line, using its hidden Edge property:
In the past three weeks I explained how HG2 (in R2014b) enables us to customize the axes rulers, back-drop, baselines, box and grid-lines in ways that were previously impossible in HG1 (R2014a or earlier). Today I will conclude the mini-series on axes customizations by describing other useful undocumented customizations of the HG2 axes:
In the past two weeks I explained how HG2 (in R2014b) enables us to customize the axes rulers, baselines, box and grid-lines in ways that were previously impossible in HG1 (R2014a or earlier). Today I will describe another useful undocumented property of the HG2 axes – Backdrop.
Last week I explained how HG2 (in R2014b) enables us to customize the axes rulers in ways that were previously impossible in HG1 (R2014a or earlier). Today I will describe other useful undocumented customizations of the HG2 axes:
Over 4 years have passed since I’ve posted my scoop on Matlab’s upcoming new graphics system (a.k.a. HG2, Handle Graphics version 2). At that time HG2 was still far from usable, but that has changed when I posted my HG2 update last year. Numerous user feedbacks, by email and blog comments, were reported and the MathWorks developers have listened and improved the code. HG2 was finally released with Matlab R2014b last Friday, and it seems at first glance to be a beauty. I hope my posts and the feedbacks have contributed, but in any case the MathWorks dev group deserves big kudos for releasing a totally new system that provides important usability and aesthetic improvements [almost] without sacrificing performance or backward-compatibility. Trust me, it’s not an easy achievement.
One of the nice things that I like about HG2 is that it provides numerous new ways to customize the objects in ways that were impossible (or nearly so) in the old HG1. In R2014b, the leap was large enough that MathWorks wisely chose to limit the official new properties to a bare minimum, for maximal HG1 compatibility. I assume that this will remain also in R2015a, which I expect to be a release devoted to bug fixing and stabilization rather than to new features. I expect the new features to start becoming official in R2015b onward. Such a measured roadmap is to be expected from a responsible engineering company such as MathWorks. So in fact there is no need at all to be disappointed at the relative lack of new functional features. They are all there already, just not yet official, and this is just as it should be.
That being said, if we are aware of the risk that these features might change in the upcoming years until they become official (if ever), then we can start using them today. Experience with this blog has shown that the vast majority of such undocumented features remain working unchanged for years, and some of them eventually become documented. For example, uitab/uitabgroup, on which I posted over 4 years ago, and which has existed almost unchanged since 2005, finally became official in R2014b after many years of running in unofficial form.
In the next few weeks I intend to present a series of posts that highlight some of the undocumented customizations in HG2. I’ll start with some new axes features, followed by plotting aspects.
Last week I explained how we can use display custom items in a standard Matlab combobox (popup/dropdown), using its underlying Java component. Today I will show how we can use this Java component for other nice customizations of the combobox’s popup:
Last week I wrote about using a variety of techniques to customize listbox items with an attached checkbox icon. Some of these methods used a standard Matlab listbox uicontrol, others used other controls. Today I wish to extend the discussion and show how Matlab listbox and combobox (pop-up) items can be customized in a variety of ways.
To add icons to listbox/combobox items, we could use standard HTML, as I’ve shown last week. This is the simplest method, requires no Java knowledge, and it usually works well. The problem is that when a listbox/combobox has numerous items (hundreds or more), it may start getting sluggish. In such case it is faster to use a dedicated Java cell-renderer that sets the icon, font, colors, tooltip and other aspects on an item-by-item basis. This runs faster and enables far greater customizability than what is possible with HTML. The drawback is that it requires some Java programming. No free lunch…
Listbox and combobox cell-renderers need to extend
javax.swing.ListCellRenderer, similarly to uitable cell-renderers. This is basically a simple Java class that minimally contains just an empty constructor and a getListCellRendererComponent() method with a predefined signature. getListCellRendererComponent() is automatically called by the Swing render engine separately for each listbox item, and gets as input args a
JList reference, the item value (typically a string), an integer list index, a boolean flag indicating whether the item is currently selected, and another flag indicating whether the item is currently in focus. getListCellRendererComponent() uses these parameters to customize and return a
java.awt.Component, which is typically (but not necessarily) a standard Swing
Here is a simple example that displays a folder of icon files in a Matlab listbox and combobox. Each item is the filename, with a customization that if the file is an icon, then this icon is displayed next to the file name, otherwise the name appears in red italic without an icon. For illustration, we’ll use Matlab’s builtin icons folder: %matlabroot%/toolbox/matlab/icons/:
Several years ago I blogged about using a checkbox-tree in Matlab. A few days ago there was a question on the Matlab Answers forum asking whether something similar can be done with Matlab listboxes, i.e. add checkboxes next to each list item. There are actually several alternatives for this and I thought this could be a good opportunity to discuss them:
- The HTML image variant
- MathWorks CheckBoxList
- JIDE’s CheckBoxList
- ActiveX and other alternatives
- Matlab uitable in disguise