Rank: 249 based on 241 downloads (last 30 days) and 14 files submitted
photo

Ben Mitch

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Ben View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
26 Jan 2012 Screenshot Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch figure, subplot, plot, multipane, specialized, panel 165 59
  • 4.44444
4.4 | 11 ratings
05 Dec 2011 datastore A tool for persisting data associated with the logged in user across sessions of Matlab. Author: Ben Mitch utility, persistent, session, data, session data 2 0
20 Dec 2010 Screenshot matml Convert between matlab variables and MatML (XML) files Author: Ben Mitch data import, data export, xml matlab variable p... 8 0
22 Nov 2010 priority Change the priority of the MATLAB Process programatically. Author: Ben Mitch development environme..., change, base, priority, process, utilities 4 12
  • 4.8
4.8 | 5 ratings
22 Nov 2010 textfile Provides a one-call interface to read/write flat text files or line-based text files. Author: Ben Mitch file, text file, read, write 4 2
Comments and Ratings by Ben View all
Updated File Comments Rating
31 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch

[edited email exchange with "Steffen"]

>> I was wondering: Is it possible to set the background color of the exported figure? I tried
>>
>> set(gcf,'Color',[0,0,0])
>>
>> In the matlab window the background is black. But after p.export the background is white again.
>>
>> What am I doing wrong :?

> set(gcf, 'Color', [0 0 0], 'InvertHardcopy', 'off')
>
> cheers
> ben

25 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch

Hi Jesper

Forgive me, I was just using Panel myself today and noticed strange behaviour with respect to smoothing and import into Word. Suddenly clicked that I was seeing what you were flagging up the other day. Sorry, I did do some testing before and thought I'd got to the bottom of what you were seeing. Clearly, not - but I understand now :).

This is fixed now for PNG and TIF filetypes which now import correctly whether smoothed or not. Looks like JPEG does not include a DPI setting at all, or at least not one that I can make work. JPEG's not very useful, here, anyway. Next release of Panel will include the fix.

Thanks for the heads up :)
Ben

18 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch

Hi Mukhtar, did you try...

p = panel.recover(gcf);

?

Cheers

04 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch

Hi Jesper

Yeah, that's right. By scaling it you're overriding the default DPI either set in the file or assumed by Word.

Some image formats can include a resolution setting (TIFF, PNG, also JPEG?). However, these settings don't propagate to the image file through Matlab's print() function (at least, not to my testing). Panel does not attempt to fix up this information after print() is called because, well, because you're the first person who's flagged it up :). I use Latex for documents, which ignores image DPI, so I'd not noticed.

Erm... It would require either binary hacking or a time-consuming imread()/imwrite() cycle, I guess, to fix it. And Matlab's imwrite() appears not to provide access to these fields for JPEGs. Potentially this could be done, would it make a big difference to you? In any case, I won't prioritise it since the scaling is easy enough.

If you're using PNG (looks like it), you could add it yourself as a read/write step after p.export(), something like:

function set_png_dpi(filename, dpi)

im = imread(filename);
dpm = dpi / 25.4 * 1000;
imwrite(im, filename, ...
  'XResolution', dpm, ...
  'YResolution', dpm, ...
  'ResolutionUnit', 'meter');

Inefficient as hell, but would do what you want. If anyone has a smarter solution, I'll gladly consider adding it to Panel.

Cheers
Ben

04 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch

Hi Jesper - thanks for your feedback.

That command produces an image size of 4019 by 2486 pixels on my machine. Without the smoothing, i.e. '-rp', it is 4019 by 2487 (i.e. only one pixel different). What sizes do you get?

Note that this is "170x105mm" only in the sense that, if you print/display that bitmap file at 600 DPI (as chosen by "p"), it will be 170x105mm in size, and the fonts, lines and symbols in the image will be at the point sizes you used when you created them. That meta-information (600 DPI) is _not_ encoded in the image file, as it can be, I believe, in a jpeg file. Thus, if you open it in something like photoshop, you may be surprised at the size it is displayed at, but that is only a matter of zoom level.

Hope that helps
Ben

Comments and Ratings on Ben's Files View all
Updated File Comment by Comments Rating
31 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch Mitch, Ben

[edited email exchange with "Steffen"]

>> I was wondering: Is it possible to set the background color of the exported figure? I tried
>>
>> set(gcf,'Color',[0,0,0])
>>
>> In the matlab window the background is black. But after p.export the background is white again.
>>
>> What am I doing wrong :?

> set(gcf, 'Color', [0 0 0], 'InvertHardcopy', 'off')
>
> cheers
> ben

25 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch Mitch, Ben

Hi Jesper

Forgive me, I was just using Panel myself today and noticed strange behaviour with respect to smoothing and import into Word. Suddenly clicked that I was seeing what you were flagging up the other day. Sorry, I did do some testing before and thought I'd got to the bottom of what you were seeing. Clearly, not - but I understand now :).

This is fixed now for PNG and TIF filetypes which now import correctly whether smoothed or not. Looks like JPEG does not include a DPI setting at all, or at least not one that I can make work. JPEG's not very useful, here, anyway. Next release of Panel will include the fix.

Thanks for the heads up :)
Ben

19 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch Ullah, Mukhtar

Thanks Ben. That is the kind of an answer I was expecting. I had this wrong perception that I can only access methods from an instance p, but you saved me!

Best regards

18 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch Mitch, Ben

Hi Mukhtar, did you try...

p = panel.recover(gcf);

?

Cheers

18 Jan 2012 Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch Ullah, Mukhtar

Sorry, I forgot one line. Following is the correct code I use

cvars = who;
    foundpanel = false;
    for i=1:numel(cvars)
        try
            foundpanel = evalin('base', ['isa(' cvars{i} ',''panel'')']);
        catch erri
        end
        if foundpanel
            break;
        end
    end

Top Tags Applied by Ben
utilities, figure, communications, development environment, example
Files Tagged by Ben View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
26 Jan 2012 Screenshot Panel Like subplot, but with easier control over the details of the layout, and WYSIWYG export to file. Author: Ben Mitch figure, subplot, plot, multipane, specialized, panel 165 59
  • 4.44444
4.4 | 11 ratings
05 Dec 2011 datastore A tool for persisting data associated with the logged in user across sessions of Matlab. Author: Ben Mitch utility, persistent, session, data, session data 2 0
20 Dec 2010 Screenshot matml Convert between matlab variables and MatML (XML) files Author: Ben Mitch data import, data export, xml matlab variable p... 8 0
22 Nov 2010 priority Change the priority of the MATLAB Process programatically. Author: Ben Mitch development environme..., change, base, priority, process, utilities 4 12
  • 4.8
4.8 | 5 ratings
22 Nov 2010 textfile Provides a one-call interface to read/write flat text files or line-based text files. Author: Ben Mitch file, text file, read, write 4 2

Contact us at files@mathworks.com