Matlab: changing the axis - image

How can you rescale the range of the axis without changing what's on the plot itself? So I would like to keep the plot, but changing the values on the axis... Thanks for your help!

In the specific case you mention in the comments: instead of using something like
imagesc(X)
use
x = linspace(0,1,size(X,1));
y = linspace(0,1,size(X,2));
imagesc(x,y,X)
This changes the axis scale, and the axis labels are set correspondingly.
In general, to change tick labels of axes, use
set(gca,'xtick',[10 20]) %// values where you want the labels placed
set(gca,'xticklabel',{'label1','label2'}) %// desired labels

Related

c3 js plotting multiple set of data on y axis w.r.t x axis, how to avoid same values not displaying on chart

i am using c3.js to plot 3 set of data on y axis and time stamp on x axis. Is there any way to avoid same values overlapping on one another. Need to display all 3 set of data irrespective of same values. Thanks in advance

Scatter line - lastly plotted point stuck to y axis or x axis, how to give buffer around it?

Scatter line - lastly plotted point stuck to y axis or x axis, how to give buffer around it?
I have masked in this picture here.
enter image description here
Ref http://demos.telerik.com/kendo-ui/scatter-charts/scatter-line
I can provide few dummy points but I would like to know out of the box method.
try adding:
panes: [{
clip: false
}]
DEMO

D3js - Adding axes to small multiples chart

I'm trying http://bl.ocks.org/mbostock/9490516 with some modifications.
I found this: D3js - adding yaxis to small multiples chart yields no or overlapped values
But it doesn't really help me.
What I would like is:
an x axis at the top of my page
an x axis at the bottom of the page
y axis for each chart with different domains
So far, I've been able to add x axis to each individual graph, but that's not what I want.
I'm able to add y axis to individual graphs, but the domain for all are the same.

dc bubble chart X axis range

Even if I set
bChart.x(d3.scale.linear().domain([0, 1000]))
It shows x-axis ticks from -200 or so. I want to remove the negative marks. Please suggest.
I just figured out the problem. It was because of the X-axis padding that I was applying unknowingly to the bChart.
I reset the padding to zero and axis domain becomes as expected.
bChart.xAxisPadding(0)

Labeling plots with images in Matlab

Is there any way of labeling plots with images. For example, when I use the following:
plot(Y(:,1),Y(:,2),'o','LineWidth',2);
gname(names)
I can label each dot in a plot with a name. Is there any way to insert images instead of names?
It is possible, but not as convenient as gname by far. You can use the low-level version of image to insert images in your plot at arbitrary positions. Here's a simple example which puts the "Mandrill" image that comes with Matlab with its upper left corner pixel at the position (pi/2, 0):
% example plot
x = linspace(0, 2*pi, 100);
plot(x, cos(x))
% insert image
load mandrill
colormap(map)
image('CData', X, 'XData', [pi/2, pi/2 + 0.5], 'YData', [0, -0.3])
The result looks like this:
Problems with this approach:
There is no interactive point-and-click facility, you have to explicitly insert and position the image labels programmatically, or program such a point-and-click facility yourself. ginput might help doing so.
A figure window can only have one associated color map. That means if you have different images, they either all have to use the same colormap or have to be truecolor images.
Not just the position, but also the display size of the image has to be specified in the call to image, and both are by default specified with respect to the plot's coordinate system. This makes it hard to achieve the correct aspect ratio. You can switch (temporarily) to absolute units using the axes property 'Units' , but then you have to figure out the correct position in e.g. absolute millimeters or inches. Moreover, images are usually indexed with vertical coordinates increasing from top to bottom, while plots usually have vertical coordinates increasing from bottom to top. This is the reason for the negative value -0.3 in the 'YData' property above.
Alternatively, you can insert images each in their own little axes sitting on top of the plot's axes, which makes it easy to get the right orientation and aspect ratio using axis image. You'll still have the problem though to figure out the correct position for the axes.

Resources